private Integer getInstanceNumByEnable(boolean isEnd) {
   if (isEnd) {
     return workflowInstanceManager.getEndInstanceNumByEnable(getCompanyId(), getCurrentUser());
   } else {
     return workflowInstanceManager.getNotEndInstanceNumByEnable(getCompanyId(), getCurrentUser());
   }
 }
示例#2
0
 /** 流程监控 减少办理人 */
 public String delTransactor() throws Exception {
   WorkflowInstance instance = null;
   if (instanceId != null) instance = workflowInstanceManager.getWorkflowInstance(instanceId);
   else instance = workflowInstanceManager.getWorkflowInstance(workflowId);
   workflowId = instance.getProcessInstanceId();
   boolean isForkTask = taskService.isForkTask(workflowId);
   if (!isForkTask) { // 表示是分支汇聚任务时不让减少办理人
     List<String[]> currentTransactors = taskService.getActivityTaskTransactors(workflowId);
     List<String> currentPrincipals = taskService.getActivityTaskPrincipals(workflowId);
     if (currentTransactors != null) {
       if (currentTransactors.size() == 1) {
         Object[] transactors = currentTransactors.get(0);
         transactor = (transactors[1]).toString();
       }
       transactorNum = currentTransactors.size();
     }
     if (currentPrincipals != null) {
       if (transactorNum == 0 && currentPrincipals.size() == 1) {
         String loginName = currentPrincipals.get(0);
         User user = acsUtils.getUserByLoginName(loginName);
         if (user != null) {
           transactor = user.getName();
         }
       }
       transactorNum = transactorNum + currentPrincipals.size();
     }
   }
   // 判断当前环节是否是子流程
   hasActivitySubProcess = taskService.getActivetySubProcess(instance.getProcessInstanceId());
   return "delTransactor";
 }
示例#3
0
 private String preView(String operate) {
   log.debug("*** preView 方法开始");
   log.debug(
       new StringBuilder("*** Received parameter:[")
           .append("task:")
           .append(task)
           .append("]")
           .toString());
   workflowInstance = workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId());
   workflowId = task.getProcessInstanceId();
   StringBuilder builder = new StringBuilder();
   builder
       .append("<input type=\"hidden\" name=\"dataId\" value=\"")
       .append(workflowInstance.getDataId())
       .append("\"/>");
   FormView form = formViewManager.getFormView(workflowInstance.getFormId());
   formHtml =
       workflowInstanceManager.setValueForHtml(workflowInstance.getDataId(), form, form.getHtml());
   formHtml = builder.toString() + formHtml;
   if (SAVE.equals(operate)) {
     formHtml =
         workflowInstanceManager.getFormHtml(
             workflowInstance, formHtml, workflowInstance.getDataId(), true, false);
     fieldPermission = ApiFactory.getFormService().getFieldPermission(task.getId());
   } else {
     formHtml =
         workflowInstanceManager.getFormHtml(
             workflowInstance, formHtml, workflowInstance.getDataId(), false, false);
     fieldPermission = workflowRightsManager.getFieldPermission(false);
   }
   ApiFactory.getBussinessLogService().log("工作流管理", "查看已完成任务", ContextUtils.getSystemId("wf"));
   log.debug("*** preView 方法结束");
   return "view";
 }
示例#4
0
  /**
   * 意见
   *
   * @return
   * @throws Exception
   */
  public String opinion() throws Exception {
    // workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId);

    // authority(workflowInstance.getProcessDefinitionId(),task.getName());

    // if(view){
    // opinions =
    // workflowInstanceManager.getOpinionsByInstanceId(workflowInstance.getProcessInstanceId(),companyId);
    // }
    if (taskId == null) {
      view = true;
    } else {
      task = taskService.getWorkflowTask(taskId);
      if (task.getActive() == 2) {
        edit = false;
      }
    }
    workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId);
    opinions = workflowInstanceManager.getOpinions(taskId, task.getCompanyId());
    if (workflowRightsManager.mustOpinionRight(BeanUtil.turnToModelTask(task))
        && (opinions == null || opinions.size() <= 0)) {
      must = true;
    } else {
      must = false;
    }
    companyId = ContextUtils.getCompanyId();
    ApiFactory.getBussinessLogService().log("流程汇编", "意见列表", ContextUtils.getSystemId("wf"));
    return "opinion";
  }
 /*
  * 根据流程实例类型查询当前用户流程实例个数
  */
 private Integer getInstanceNumByType(Long typeId, boolean isEnd) {
   if (isEnd) {
     return workflowInstanceManager.getEndInstanceNumByCreatorAndType(
         getCompanyId(), getCurrentUser(), typeId);
   } else {
     return workflowInstanceManager.getNotEndInstanceNumByCreatorAndType(
         getCompanyId(), getCurrentUser(), typeId);
   }
 }
 /*
  * 根据流程定义查询流程实例个数
  */
 private Integer getInstanceNumByDefinition(WorkflowDefinition definition, boolean isEnd) {
   if (isEnd) {
     return workflowInstanceManager.getEndInstanceNumByDefinition(
         getCompanyId(), getCurrentUser(), definition);
   } else {
     return workflowInstanceManager.getNotEndInstanceNumByDefinition(
         getCompanyId(), getCurrentUser(), definition);
   }
 }
示例#7
0
 /** 流程监控 增加办理人 */
 public String addTransactor() throws Exception {
   if (instanceId != null)
     workflowInstance = workflowInstanceManager.getWorkflowInstance(instanceId);
   else workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId);
   workflowId = workflowInstance.getProcessInstanceId();
   forkTask = taskService.isForkTask(workflowId);
   // 判断当前环节是否是子流程
   hasActivitySubProcess =
       taskService.getActivetySubProcess(workflowInstance.getProcessInstanceId());
   return "addTransactor";
 }
示例#8
0
 /** 流程监控 更改办理人 */
 public String changeTransactor() throws Exception {
   if (instanceId != null)
     workflowInstance = workflowInstanceManager.getWorkflowInstance(instanceId);
   else workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId);
   taskList =
       taskService.getActivityTasks(
           workflowInstance.getProcessInstanceId(), ContextUtils.getCompanyId());
   // 判断当前环节是否是子流程
   hasActivitySubProcess =
       taskService.getActivetySubProcess(workflowInstance.getProcessInstanceId());
   return "changeTransactor";
 }
示例#9
0
 /** 保存审批结果 */
 public String saveOpinion() throws Exception {
   workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId);
   Opinion opi = new Opinion();
   opi.setTransactor(ContextUtils.getUserName());
   opi.setCreatedTime(new Date());
   opi.setOpinion(opinion);
   opi.setWorkflowId(workflowInstance.getProcessInstanceId());
   opi.setCompanyId(ContextUtils.getCompanyId());
   opi.setTaskId(taskId);
   workflowInstanceManager.saveOpinion(opi);
   ApiFactory.getBussinessLogService().log("流程汇编", "保存意见", ContextUtils.getSystemId("wf"));
   return opinion();
 }
示例#10
0
 /** 处理任务 */
 @Override
 public String input() throws Exception {
   log.debug("*** input 处理任务方法开始");
   log.debug(
       new StringBuilder("*** Received parameter:[")
           .append("task:")
           .append(task)
           .append("]")
           .toString());
   taskService.updateTaskIsRead(task);
   workflowId = task.getProcessInstanceId();
   workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId);
   opinions = workflowInstanceManager.getOpinions(taskId, task.getCompanyId());
   if (workflowRightsManager.mustOpinionRight(BeanUtil.turnToModelTask(task))
       && (opinions == null || opinions.size() <= 0)) {
     must = true;
   }
   StringBuilder builder = new StringBuilder();
   builder
       .append("<input type=\"hidden\" name=\"dataId\" value=\"")
       .append(workflowInstance.getDataId())
       .append("\"/>");
   formHtml =
       workflowInstanceManager.getHtml(
           workflowInstance.getProcessDefinitionId(),
           workflowInstance.getFormId(),
           workflowInstance.getDataId(),
           task.getName());
   formHtml = builder.toString() + formHtml;
   if (TaskState.COMPLETED.getIndex().equals(task.getActive())
       || TaskState.CANCELLED.getIndex().equals(task.getActive())) {
     // 列表控件控制
     formHtml =
         workflowInstanceManager.getFormHtml(
             workflowInstance, formHtml, workflowInstance.getDataId(), false, false);
     fieldPermission = workflowRightsManager.getFieldPermission(false);
   } else if (TaskState.WAIT_CHOICE_TACHE.getIndex().equals(task.getActive())) {
     canChoiceTaches = taskService.isNeedChoiceTache(task, workflowInstance).getCanChoiceTaches();
     return choiceTache();
   } else {
     // 列表控件控制
     formHtml =
         workflowInstanceManager.getFormHtml(
             workflowInstance, formHtml, workflowInstance.getDataId(), true, false);
     fieldPermission = ApiFactory.getFormService().getFieldPermission(task.getId());
   }
   ApiFactory.getBussinessLogService().log("工作流管理", "任务办理页面", ContextUtils.getSystemId("wf"));
   log.debug("*** input 处理任务方法结束");
   return INPUT;
 }
示例#11
0
 /**
  * 批量环节跳转/选择环节
  *
  * @return
  * @throws Exception
  */
 @Action("task-volumeBackView")
 public String volumeBackView() throws Exception {
   String[] str = instanceIds.split(",");
   workflowIds = "";
   for (String s : str) {
     workflowInstance = workflowInstanceManager.getWorkflowInstance(Long.valueOf(s));
     if (workflowInstance != null) wfdId = workflowInstance.getWorkflowDefinitionId();
     workflowId = workflowInstance.getProcessInstanceId();
     boolean isForkTask = taskService.isForkTask(workflowId);
     if (!isForkTask) { // 当前任务是分支汇聚任务时不让跳转
       List<String> temp = taskService.getTaskNames(workflowId);
       if (temp != null && temp.size() > 0) {
         if (StringUtils.isNotEmpty(workflowIds)) {
           workflowIds += ",";
         }
         canBackTo = temp;
         workflowIds += workflowId;
       }
     } else {
       break;
     }
   }
   if (canBackTo == null) {
     canBackTo = new ArrayList<String>();
   }
   ApiFactory.getBussinessLogService().log("流程监控", "批量环节跳转选择环节页面", ContextUtils.getSystemId("wf"));
   return SUCCESS;
 }
示例#12
0
 /**
  * 环节跳转功能
  *
  * @return
  * @throws Exception
  */
 public String goback() throws Exception {
   String msg = "任务跳转成功";
   try {
     CompleteTaskTipType result = null;
     workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId);
     result = taskService.taskJump(workflowInstance, backto, transactors, null, false);
     switch (result) {
       case OK:
         msg = "OK";
         break;
       case RETURN_URL:
         msg = "RETURN_URL";
         break;
       case SINGLE_TRANSACTOR_CHOICE:
         User temp;
         for (String tran : result.getCanChoiceTransactor()) {
           temp = userManager.getUserByLoginName(tran);
           if (temp != null)
             canChoiceTransacators = canChoiceTransacators + tran + "," + temp.getName() + ";";
         }
         msg = "SINGLE_TRANSACTOR_CHOICE";
         break;
       case MESSAGE:
         msg = result.getContent();
     }
   } catch (Exception e) {
     PropUtils.getExceptionInfo(e);
     msg = "环节跳转失败";
   }
   ApiFactory.getBussinessLogService().log("流程监控", "执行环节跳转", ContextUtils.getSystemId("wf"));
   renderText(msg + "=" + canChoiceTransacators);
   return null;
 }
示例#13
0
  /** 提交表单 */
  public String submit() throws Exception {
    log.debug("*** submit 方法开始");
    log.debug(
        new StringBuilder("*** Received parameter:[")
            .append("taskId:")
            .append(taskId)
            .append("]")
            .toString());

    task = taskService.getWorkflowTask(taskId);
    String to = "";
    CompleteTaskTipType result = workflowInstanceManager.submitForm(task);
    switch (result) {
      case OK:
        this.addSuccessMessage(result.getContent());
        to = input();
        break;
      case MESSAGE:
        this.addErrorMessage(result.getContent());
        to = INPUT;
        break;
      case RETURN_URL:
        to = assignTransactor();
        break;
      case TACHE_CHOICE_URL:
        canChoiceTaches = result.getCanChoiceTaches();
        to = choiceTache();
        break;
    }
    ApiFactory.getBussinessLogService().log("工作流管理", "提交表单", ContextUtils.getSystemId("wf"));
    return to;
  }
示例#14
0
  @Transactional(readOnly = false)
  public void run() throws Exception {
    List<Company> companys = acsUtils.getAllCompanys();
    for (Company company : companys) {
      ThreadParameters parameters = new ThreadParameters(company.getId());
      ParameterUtils.setParameters(parameters);
      String systemAdmin = ApiFactory.getAcsService().getSystemAdminLoginName();
      parameters = new ThreadParameters(company.getId());
      parameters.setUserName("系统");
      parameters.setLoginName(systemAdmin);
      ParameterUtils.setParameters(parameters);

      // 委托
      delegateMain();

      // 催办
      List<WorkflowTask> result = new ArrayList<WorkflowTask>();
      result.addAll(workflowInstanceManager.getNeedReminderTasksByInstance());
      result.addAll(taskService.getNeedReminderTasks());
      reminder(result);
    }
    deleteExportTempFile();

    // 清空同步处理时的实例map,见TaskService中的completeInteractiveWorkflowTask方法
    TaskService.instanceIds.clear();
  }
示例#15
0
 public String choiceTachePop() throws Exception {
   if (canChoiceTaches == null) {
     workflowInstance = workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId());
     canChoiceTaches = taskService.isNeedChoiceTache(task, workflowInstance).getCanChoiceTaches();
   }
   ApiFactory.getBussinessLogService().log("工作流管理", "弹出选择环节页面", ContextUtils.getSystemId("wf"));
   return "choiceUrlPop";
 }
 // 新建word/excel
 @Action("office-createOffice")
 public String createOffice() throws Exception {
   WorkflowInstance instance = null;
   WorkflowTask task = null;
   if (id == null) {
     task = ApiFactory.getTaskService().getTask(taskId);
     instance = workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId());
     document.setTaskName(task.getName());
     document.setTaskMode(task.getProcessingMode());
     document.setWorkflowId(instance.getProcessInstanceId());
     document.setCreator(ContextUtils.getLoginName());
     document.setCreatorName(ContextUtils.getUserName());
     document.setCompanyId(ContextUtils.getCompanyId());
     document.setEditType("-1,0,0,0,0,0,1,1"); // 允许编辑,不显示和保留痕迹,允许批注
     document.setPrintSetting(true);
     document.setDownloadSetting(true);
     if (document.getFileType().equalsIgnoreCase("pdf")) {
       return "office-pdf";
     } else {
       String template =
           DefinitionXmlParse.getOfficialTextTemplate(
               instance.getProcessDefinitionId(), task.getName());
       if (StringUtils.isNotEmpty(template))
         document.setTemplateId(Long.valueOf(StringUtils.substringBetween(template, "[", "]")));
       setOfficeRight(document, instance, task);
       return "office-view";
     }
   } else {
     if (taskId == null) {
       instance = workflowInstanceManager.getWorkflowInstance(document.getWorkflowId());
       task = ApiFactory.getTaskService().getTask(instance.getFirstTaskId());
     } else {
       task = ApiFactory.getTaskService().getTask(taskId);
       instance = workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId());
     }
     setOfficeRight(document, instance, task);
     if (document.getFileType().equalsIgnoreCase("pdf")) {
       return "office-pdf";
     } else {
       return "office-view";
     }
   }
 }
示例#17
0
 /**
  * 流程监控/保存更改的办理人
  *
  * @return
  * @throws Exception
  */
 public String changeTransactorSave() throws Exception {
   taskService.changeTransactor(taskId, transactor);
   task = taskService.getWorkflowTask(taskId);
   workflowId = task.getProcessInstanceId();
   workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId);
   // 更改办理人业务补偿
   taskService.changeTransactorSet(workflowInstance, transactor, task.getId());
   ApiFactory.getBussinessLogService().log("流程监控", "更改办理人", ContextUtils.getSystemId("wf"));
   this.addSuccessMessage("办理人已更改");
   return changeTransactor();
 }
示例#18
0
 /**
  * 环节跳转/选择环节
  *
  * @return
  * @throws Exception
  */
 public String backView() throws Exception {
   workflowInstance = workflowInstanceManager.getWorkflowInstance(instanceId);
   if (workflowInstance != null) wfdId = workflowInstance.getWorkflowDefinitionId();
   workflowId = workflowInstance.getProcessInstanceId();
   boolean isForkTask = taskService.isForkTask(workflowId);
   if (!isForkTask) { // 当前任务是分支汇聚任务时不让跳转
     canBackTo = taskService.getTaskNames(workflowId);
   } else {
     canBackTo = new ArrayList<String>();
   }
   ApiFactory.getBussinessLogService().log("流程监控", "环节跳转选择环节页面", ContextUtils.getSystemId("wf"));
   return "goback";
 }
示例#19
0
 /** 指定办理人 */
 @Action(value = "taskassign")
 public String assignTransactor() throws Exception {
   String to = INPUT;
   if (task.getId() == null) {
     this.addErrorMessage("非法的任务");
   } else {
     WorkflowInstance instance =
         workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId());
     CompleteTaskTipType result = taskService.isNeedAssigningTransactor(instance, task);
     if (result == null) {
       result = taskService.isSubProcessNeedChoiceTransactor(task, instance);
     }
     switch (result) {
       case OK:
         this.addSuccessMessage(result.getContent());
         to = input();
         break;
       case MESSAGE:
         this.addErrorMessage(result.getContent());
         to = INPUT;
         break;
       case RETURN_URL:
         candidates = taskService.getNextTasksCandidates(task);
         this.addErrorMessage("请选择办理人");
         to = "assign";
         break;
       case TACHE_CHOICE_URL:
         addActionMessage("请选择环节");
         canChoiceTaches = result.getCanChoiceTaches();
         to = choiceTache();
       case SINGLE_TRANSACTOR_CHOICE:
         User temp;
         for (String tran : result.getCanChoiceTransactor()) {
           temp = userManager.getUserByLoginName(tran);
           if (temp != null) canChoiceTransactor.put(tran, temp.getName());
         }
         moreTransactor = CompleteTaskTipType.SINGLE_TRANSACTOR_CHOICE.getContent().equals("true");
         to = "singleTransactorChoice";
     }
   }
   ApiFactory.getBussinessLogService().log("工作流管理", "指定办理人", ContextUtils.getSystemId("wf"));
   return to;
 }
示例#20
0
  @SuppressWarnings("unchecked")
  public String start() throws Exception {
    log.debug("*** start 方法开始");
    log.debug(
        new StringBuilder("*** Received parameter:[")
            .append("processId:")
            .append(processId)
            .append("]")
            .toString());

    WorkflowDefinition wdf = workflowDefinitionManager.getWorkflowDefinitionByProcessId(processId);
    String wfdName = wdf.getName();
    String url =
        Struts2Utils.getRequest()
            .getRequestURL()
            .toString()
            .replaceFirst("task!start", "task!input");
    Map<String, String> urlMap = new HashMap<String, String>();
    urlMap.put(wfdName, url);
    Integer priority = 6;
    Map<String, String[]> parameterMap = Struts2Utils.getRequest().getParameterMap();
    String[] urgency = parameterMap.get(URGENCY);
    if (urgency != null && urgency.length > 0 && StringUtils.isNotEmpty(urgency[0]))
      priority = Integer.valueOf(urgency[0]);
    String to = "";
    CompleteTaskTipType result =
        workflowInstanceManager.startAndSubmitWorkflow(processId, urlMap, priority, null);
    switch (result) {
      case OK:
        this.addSuccessMessage(result.getContent());
        to = null;
        break;
      case MESSAGE:
        this.addErrorMessage(result.getContent());
        to = null;
        break;
      case RETURN_URL:
        to = assignTransactor();
        break;
    }
    ApiFactory.getBussinessLogService().log("工作流管理", "发起流程", ContextUtils.getSystemId("wf"));
    return to;
  }
示例#21
0
 /** 保存表单 */
 public String saveForm() throws Exception {
   workflowInstanceManager.saveFormData(taskId);
   ApiFactory.getBussinessLogService().log("工作流管理", "保存表单", ContextUtils.getSystemId("wf"));
   this.addSuccessMessage("任务已保存");
   return input();
 }
示例#22
0
 /** 保存任务 */
 @Override
 public String save() throws Exception {
   log.debug("*** save 办理任务方法开始");
   log.debug(
       new StringBuilder("*** Received parameter:[")
           .append("task:")
           .append(task)
           .append("]")
           .toString());
   ApiFactory.getBussinessLogService().log("工作流管理", "保存任务", ContextUtils.getSystemId("wf"));
   // 如果为分发环节,指定被分发人
   if (TaskProcessingMode.TYPE_DISTRIBUTE.toString().equals(task.getProcessingMode().toString())) {
     return "distribute";
   }
   // 如果为交办环节,指定被交办人
   if (task.getActive() == 0
       && TaskProcessingMode.TYPE_ASSIGN.toString().equals(task.getProcessingMode().toString())) {
     moreTransactor = true;
     workflowInstanceManager.saveData(task, null);
     return "assignTree";
   }
   // 如果已经办理但没有指定办理人
   if (task.getActive() == 1 && task.getProcessingMode() != TaskProcessingMode.TYPE_ASSIGN) {
     return assignTransactor();
   }
   String to = "";
   try {
     CompleteTaskTipType result =
         taskService.completeWorkflowTaskAndSaveData(
             task,
             transact,
             TaskSetting.getTaskSettingInstance()
                 .setTransitionName(transitionName)
                 .setAssignmentTransactors(newTransactor));
     switch (result) {
       case OK:
         this.addSuccessMessage(result.getContent());
         to = input();
         break;
       case MESSAGE:
         this.addErrorMessage(result.getContent());
         to = INPUT;
         break;
       case RETURN_URL:
         to = assignTransactor();
         break;
       case TACHE_CHOICE_URL:
         addActionMessage("请选择环节");
         canChoiceTaches = result.getCanChoiceTaches();
         to = choiceTache();
         break;
       case SINGLE_TRANSACTOR_CHOICE:
         User temp;
         for (String tran : result.getCanChoiceTransactor()) {
           temp = userManager.getUserByLoginName(tran);
           if (temp != null) canChoiceTransactor.put(tran, temp.getName());
         }
         moreTransactor = CompleteTaskTipType.SINGLE_TRANSACTOR_CHOICE.getContent().equals("true");
         to = "singleTransactorChoice";
     }
   } catch (TransactorAssignmentException e) {
     nullAssignmentException = "下一环节没有办理人,请指定!";
     return "assignmentTree";
   } catch (DecisionException de) {
     transitionNames = de.getTransitionNames();
     messageTip = de.getMessage();
     messageTip = getText(messageTip);
     return input();
   }
   return to;
 }
 /*
  * 根据条件选定办理人
  * @param conditions
  * @param creator
  * @param _wf_transactor
  * @return
  */
 public static Set<String> processCondition(
     Map<TaskTransactorCondition, String> conditions,
     OpenExecution execution,
     Map<String, String> param) {
   Long companyId = ContextUtils.getCompanyId();
   if (companyId == null) {
     Object compIdStr = execution.getVariable(CommonStrings.COMPANY_ID);
     if (compIdStr != null) {
       companyId = Long.parseLong(compIdStr.toString());
     }
   }
   String userCondition = conditions.get(TaskTransactorCondition.USER_CONDITION);
   if (userCondition == null) {
     throw new RuntimeException("办理人设置中,解析条件时,设置的条件不能为null");
   }
   // 根据条件获取办理人
   Set<String> candidates = new HashSet<String>();
   if ("${documentCreator}".equals(userCondition)) {
     // 文档创建人
     candidates.add(param.get(DOCUMENT_CREATOR));
   } else if ("${previousTransactorAssignment}".equals(userCondition)) {
     // 上一环节办理人指定
     candidates.add(CommonStrings.TRANSACTOR_ASSIGNMENT);
   } else if (userCondition.startsWith("${field[")) {
     // 文档字段中指定//${field[name_zn[name_en]]}
     int start = userCondition.lastIndexOf("[");
     int end = userCondition.indexOf("]");
     String fieldName = userCondition.substring(start + 1, end);
     // 根据流程实例ID获取流程表单中指定字段的值
     WorkflowInstanceManager manager =
         (WorkflowInstanceManager) ContextUtils.getBean("workflowInstanceManager");
     String fieldValues = manager.getFieldValueInForm(param.get(PROCESS_INSTANCEID), fieldName);
     if (fieldValues == null) {
       throw new RuntimeException("办理人设置中,文档字段中指定时,该字段的值不能为null");
     }
     for (String fieldValue : fieldValues.split(",")) {
       fieldValue = fieldValue.trim();
       if (StringUtils.isNotEmpty(fieldValue)) {
         if ("ALLCOMPANYID".equals(fieldValue)) { // 所有人员(不包含无部门人员)
           List<String> loginNames = ApiFactory.getAcsService().getLoginNamesByCompany(companyId);
           candidates.addAll(loginNames);
         } else if ("ALLWORKGROUP".equals(fieldValue)) { // 所有工作组中的人员
           List<String> loginNames =
               ApiFactory.getAcsService().getLoginNamesByWorkgroup(companyId);
           candidates.addAll(loginNames);
         } else {
           candidates.add(fieldValue);
         }
       }
     }
   } else {
     if (execution == null) {
       throw new RuntimeException("办理人设置中,解析条件时,execution不能为null");
     }
     FormViewManager formManager = (FormViewManager) ContextUtils.getBean("formViewManager");
     WorkflowInstanceManager workflowInstanceManager =
         (WorkflowInstanceManager) ContextUtils.getBean("workflowInstanceManager");
     WorkflowInstance wi =
         workflowInstanceManager.getWorkflowInstance(param.get(PROCESS_INSTANCEID), companyId);
     if (wi == null) {
       throw new RuntimeException("办理人设置中,解析条件时,流程实例不能为null");
     }
     FormView form = formManager.getFormView(wi.getFormId());
     UserParseCalculator upc = new UserParseCalculator();
     upc.setDataId(wi.getDataId());
     upc.setFormView(form);
     upc.setDocumentCreator(param.get(DOCUMENT_CREATOR));
     upc.setPreviousTransactor(param.get(PREVIOUS_TRANSACTOR));
     upc.setCurrentTransactor(param.get(CURRENT_TRANSACTOR));
     upc.setProcessAdmin(param.get(PROCESS_ADMIN));
     candidates.addAll(
         processAdditionalCondition(
             conditions,
             upc.getUsers(userCondition, wi.getSystemId(), wi.getCompanyId()),
             param.get(DOCUMENT_CREATOR),
             execution));
   }
   return candidates;
 }
  /*
   * 根据附加条件过滤办理人
   * @param conditions
   * @param candidates
   * @param creator
   * @param _wf_transactor
   * @return
   */
  private static Set<String> processAdditionalCondition(
      Map<TaskTransactorCondition, String> conditions,
      Set<String> candidates,
      String creator,
      OpenExecution execution) {

    Set<String> results = new HashSet<String>();
    String selectOne = conditions.get(TaskTransactorCondition.SELECT_ONE_FROM_MULTIPLE);
    String onlyInCreatorDept = conditions.get(TaskTransactorCondition.ONLY_IN_CREATOR_DEPARTMENT);
    String withCreatorDept = conditions.get(TaskTransactorCondition.WITH_CREATOR_DEPARTMENT);
    if ("true".equals(onlyInCreatorDept) || "true".equals(withCreatorDept)) {
      List<String[]> usersInSameDept =
          AcsApi.getUsersInSameDept(ContextUtils.getCompanyId(), creator);

      // 只能为创建人部门(交集)
      if ("true".equals(onlyInCreatorDept)) {
        for (String[] user1 : usersInSameDept) {
          if (candidates.contains(user1[1])) {
            results.add(user1[1]);
          }
        }
      } else {
        results.addAll(candidates);
      }
      // 创建人部门参与(并集)
      if ("true".equals(withCreatorDept)) {
        for (String[] user1 : usersInSameDept) {
          results.add(user1[1]);
        }
      }
    } else {
      results.addAll(candidates);
    }
    Set<String> latest = new HashSet<String>();
    // 需要唯一指定办理人
    if ("true".equals(selectOne)) {
      //			  <select-type>autoType</select-type>
      //	          <select-bean>workflowInstanceManager</select-bean>
      // 只有一个候选人
      if (conditions
          .get(TaskTransactorCondition.SELECT_TYPE)
          .equals(TaskTransactorCondition.SELECT_TYPE_CUSTOM)) {
        //					if(results.size() == 1){
        //						latest.add(results.iterator().next());
        //					}else if(results.size() > 1){
        latest.add(CommonStrings.TRANSACTOR_SINGLE);
        // 将候选人加入到execution变量中
        execution.createVariable(CommonStrings.TRANSACTOR_SINGLE_CANDIDATES, results);
        //					}
      } else {
        WorkflowInstanceManager workflowInstanceManager =
            (WorkflowInstanceManager) ContextUtils.getBean("workflowInstanceManager");
        WorkflowInstance instance =
            workflowInstanceManager.getWorkflowInstance(
                execution.getProcessInstance().getProcessInstance().getId());
        if (instance == null) {
          throw new RuntimeException("办理人设置中,解析附加条件时,流程实例不能为null");
        }
        String selectorBeanName = conditions.get(TaskTransactorCondition.SELECT_BEAN);
        ActivityExecution activityExecution = (ActivityExecution) execution;
        String activityName = activityExecution.getActivityName();
        if (StringUtils.isEmpty(selectorBeanName))
          throw new WorkflowException("环节:" + activityName + "没有指定自动选择办理人的bean名");
        SingleTransactorSelector selector =
            (SingleTransactorSelector) ContextUtils.getBean(selectorBeanName);
        boolean moreTransactor =
            DefinitionXmlParse.hasMoreTransactor(instance.getProcessDefinitionId(), activityName);
        Set<String> result = selector.filter(instance.getDataId(), results, moreTransactor);
        Iterator<String> it = result.iterator();
        while (it.hasNext()) {
          latest.add(it.next());
        }
      }
    } else {
      for (String user : results) {
        latest.add(user);
      }
    }
    return latest;
  }
示例#25
0
 /**
  * 只保存数据,与流程无关
  *
  * @return
  * @throws Exception
  */
 public String savaData() throws Exception {
   dataId = workflowInstanceManager.savaData();
   ApiFactory.getBussinessLogService().log("工作流管理", "保存数据", ContextUtils.getSystemId("wf"));
   return null;
 }