예제 #1
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";
 }
예제 #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
 /**
  * 批量环节跳转/选择环节
  *
  * @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;
 }
예제 #4
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";
 }
예제 #5
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";
 }
예제 #6
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";
 }
예제 #7
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";
     }
   }
 }
예제 #8
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();
 }
예제 #9
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;
 }
 /*
  * 根据条件选定办理人
  * @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;
  }