コード例 #1
0
ファイル: TaskAction.java プロジェクト: songfj/5.2.1.RC
 /** 处理任务 */
 @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;
 }
コード例 #2
0
 // 新建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";
     }
   }
 }
コード例 #3
0
  /*
   * 根据附加条件过滤办理人
   * @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;
  }