@Override
  public void costWorkFlowStart(CostApprovalEntity costApproval, HttpServletRequest request) {
    // 由session取到登录用户id
    String applyUserId = ResourceUtil.getSessionUserName().getId();
    this.save(costApproval);
    String processKey = request.getParameter("processKey");
    if (!StringUtil.isNotEmpty(processKey)) {
      WorkFlowSetEntity workFlowSet =
          this.findUniqueByProperty(
              WorkFlowSetEntity.class, "entityName", costApproval.getClass().getSimpleName());
      processKey = workFlowSet.getProcessKey();
    }
    String businessKey = costApproval.getId().toString();
    ProcessInstance processInstance = null;
    // 用来设置启动流程的人员ID,引擎会自动把用户ID保存到activiti:initiator中
    identityService.setAuthenticatedUserId(applyUserId);

    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put(ProcessConstantsUtil.getApplyUserId(), applyUserId);
    processInstance = runtimeService.startProcessInstanceByKey(processKey, businessKey, variables);
    String processInstanceId = processInstance.getId();
    costApproval.setProcessinstanceId(processInstanceId);

    // 获取并执行当前流程实例的下一步任务
    Task task = null;
    TaskQuery query =
        taskService.createTaskQuery().processInstanceBusinessKey(businessKey).active();
    task = query.singleResult();
    variables.put(
        ProcessConstantsUtil.getDeptLeaderId(),
        ResourceUtil.getSessionUserName().getCurrentDepart().getDepartManager().getId());
    taskService.complete(task.getId(), variables);
  }
Esempio n. 2
0
  /**
   * easyui AJAX请求数据 已办任务
   *
   * @param request
   * @param response
   * @param dataGrid
   */
  @RequestMapping(params = "finishedTaskDataGrid")
  public void finishedTask(
      HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {

    // String userId = "leaderuser";
    String userId = ResourceUtil.getSessionUserName().getId();
    List<HistoricTaskInstance> historicTasks =
        historyService.createHistoricTaskInstanceQuery().taskAssignee(userId).finished().list();

    StringBuffer rows = new StringBuffer();
    for (HistoricTaskInstance t : historicTasks) {
      rows.append(
          "{'name':'"
              + t.getName()
              + "','description':'"
              + t.getDescription()
              + "','taskId':'"
              + t.getId()
              + "','processDefinitionId':'"
              + t.getProcessDefinitionId()
              + "','processInstanceId':'"
              + t.getProcessInstanceId()
              + "'},");
    }
    String rowStr = StringUtils.substringBeforeLast(rows.toString(), ",");

    JSONObject jObject =
        JSONObject.fromObject("{'total':" + historicTasks.size() + ",'rows':[" + rowStr + "]}");
    responseDatagrid(response, jObject);
  }
Esempio n. 3
0
  /**
   * easyui AJAX请求数据 待领任务
   *
   * @param request
   * @param response
   * @param dataGrid
   */
  @RequestMapping(params = "waitingClaimTaskDataGrid")
  public void waitingClaimTaskDataGrid(
      HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {

    // String userId = "hruser";
    String userId = ResourceUtil.getSessionUserName().getId();
    TaskService taskService = processEngine.getTaskService();
    List<Task> tasks =
        taskService
            .createTaskQuery()
            .taskCandidateUser(userId)
            .active()
            .list(); // .taskCandidateGroup("hr").active().list();

    StringBuffer rows = new StringBuffer();
    for (Task t : tasks) {
      rows.append(
          "{'name':'"
              + t.getName()
              + "','taskId':'"
              + t.getId()
              + "','processDefinitionId':'"
              + t.getProcessDefinitionId()
              + "'},");
    }
    String rowStr = StringUtils.substringBeforeLast(rows.toString(), ",");

    JSONObject jObject =
        JSONObject.fromObject("{'total':" + tasks.size() + ",'rows':[" + rowStr + "]}");
    responseDatagrid(response, jObject);
  }
Esempio n. 4
0
  /**
   * 签收任务
   *
   * @param taskId
   */
  @RequestMapping(params = "claimTask")
  @ResponseBody
  public AjaxJson claimTask(@RequestParam("taskId") String taskId, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();

    // String userId = "leaderuser";
    String userId = ResourceUtil.getSessionUserName().getId();
    TaskService taskService = processEngine.getTaskService();
    taskService.claim(taskId, userId);

    String message = "签收成功";
    j.setMsg(message);
    return j;
  }
  /**
   * 导出excel
   *
   * @param request
   * @param response
   */
  @RequestMapping(params = "exportXls")
  public void exportXls(
      WeixinCmsSiteEntity weixinCmsSite,
      HttpServletRequest request,
      HttpServletResponse response,
      DataGrid dataGrid) {
    response.setContentType("application/vnd.ms-excel");
    String codedFileName = null;
    OutputStream fOut = null;
    try {
      codedFileName = "微站点信息";
      // 根据浏览器进行转码,使其支持中文文件名
      if (BrowserUtils.isIE(request)) {
        response.setHeader(
            "content-disposition",
            "attachment;filename=" + java.net.URLEncoder.encode(codedFileName, "UTF-8") + ".xls");
      } else {
        String newtitle = new String(codedFileName.getBytes("UTF-8"), "ISO8859-1");
        response.setHeader("content-disposition", "attachment;filename=" + newtitle + ".xls");
      }
      // 产生工作簿对象
      HSSFWorkbook workbook = null;
      CriteriaQuery cq = new CriteriaQuery(WeixinCmsSiteEntity.class, dataGrid);
      org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(
          cq, weixinCmsSite, request.getParameterMap());

      List<WeixinCmsSiteEntity> weixinCmsSites =
          this.weixinCmsSiteService.getListByCriteriaQuery(cq, false);
      workbook =
          ExcelExportUtil.exportExcel(
              new ExcelTitle(
                  "微站点信息列表", "导出人:" + ResourceUtil.getSessionUserName().getRealName(), "导出信息"),
              WeixinCmsSiteEntity.class,
              weixinCmsSites);
      fOut = response.getOutputStream();
      workbook.write(fOut);
    } catch (Exception e) {
    } finally {
      try {
        fOut.flush();
        fOut.close();
      } catch (IOException e) {

      }
    }
  }
  /**
   * 导出excel 使模板
   *
   * @param request
   * @param response
   */
  @RequestMapping(params = "exportXlsByT")
  public void exportXlsByT(
      WeixinCmsSiteEntity weixinCmsSite,
      HttpServletRequest request,
      HttpServletResponse response,
      DataGrid dataGrid) {
    response.setContentType("application/vnd.ms-excel");
    String codedFileName = null;
    OutputStream fOut = null;
    try {
      codedFileName = "微站点信息";
      // 根据浏览器进行转码,使其支持中文文件名
      if (BrowserUtils.isIE(request)) {
        response.setHeader(
            "content-disposition",
            "attachment;filename=" + java.net.URLEncoder.encode(codedFileName, "UTF-8") + ".xls");
      } else {
        String newtitle = new String(codedFileName.getBytes("UTF-8"), "ISO8859-1");
        response.setHeader("content-disposition", "attachment;filename=" + newtitle + ".xls");
      }
      // 产生工作簿对象
      HSSFWorkbook workbook = null;
      workbook =
          ExcelExportUtil.exportExcel(
              new ExcelTitle(
                  "微站点信息列表", "导出人:" + ResourceUtil.getSessionUserName().getRealName(), "导出信息"),
              WeixinCmsSiteEntity.class,
              null);
      fOut = response.getOutputStream();
      workbook.write(fOut);
    } catch (Exception e) {
    } finally {
      try {
        fOut.flush();
        fOut.close();
      } catch (IOException e) {

      }
    }
  }
  @Override
  public void completeTask(CostApprovalEntity costApproval, HttpServletRequest request) {
    String taskId = request.getParameter("taskId"); // 任务id
    String taskKey = request.getParameter("taskKey"); // 任务步骤
    String auditType = request.getParameter("auditType"); // 是否同意
    String postil = request.getParameter("postil"); // 批注信息
    Map<String, Object> variables = taskService.getVariables(taskId);
    if (taskKey.equals(ProcessConstantsUtil.getDeptLeaderAudit())) {
      variables.put(ProcessConstantsUtil.getDeptLeaderPass(), "0".equals(auditType) ? false : true);
      variables.put(
          ProcessConstantsUtil.getLeaderManagerId(),
          ResourceUtil.getSessionUserName().getCurrentDepart().getManagerLeader().getId());
    } else if (taskKey.equals(ProcessConstantsUtil.getLeaderManagerAudit())) {
      variables.put(
          ProcessConstantsUtil.getLeaderManagerPass(), "0".equals(auditType) ? false : true);
    }
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    if (postil != null) {
      taskService.addComment(taskId, task.getProcessInstanceId(), postil);
    }

    taskService.complete(taskId, variables);
  }
  /**
   * 导出excel
   *
   * @param request
   * @param response
   */
  @SuppressWarnings("unchecked")
  @RequestMapping(params = "exportXls")
  public void exportXls(
      TerminalInfoEntity terminalInfo,
      HttpServletRequest request,
      HttpServletResponse response,
      DataGrid dataGrid) {
    response.setContentType("application/vnd.ms-excel");
    String codedFileName = null;
    OutputStream fOut = null;
    try {
      codedFileName = "终端信息";
      // 根据浏览器进行转码,使其支持中文文件名
      if (BrowserUtils.isIE(request)) {
        response.setHeader(
            "content-disposition",
            "attachment;filename=" + java.net.URLEncoder.encode(codedFileName, "UTF-8") + ".xls");
      } else {
        String newtitle = new String(codedFileName.getBytes("UTF-8"), "ISO8859-1");
        response.setHeader("content-disposition", "attachment;filename=" + newtitle + ".xls");
      }
      // 产生工作簿对象
      HSSFWorkbook workbook = null;
      CriteriaQuery cq = new CriteriaQuery(TerminalInfoEntity.class, dataGrid);
      org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(
          cq, terminalInfo, request.getParameterMap());

      List<TerminalInfoEntity> courses = systemService.getListByCriteriaQuery(cq, false);
      List<TerminalInfoPage> pages = new ArrayList<TerminalInfoPage>();
      // 转换代码为汉字
      for (TerminalInfoEntity t : courses) {
        TerminalInfoPage p = new TerminalInfoPage();
        MyBeanUtils.copyBeanNotNull2Bean(t, p);

        // 组织结构
        TSTerritory te = systemService.get(TSTerritory.class, t.getGroupid());
        if (te != null) {
          p.setGroupname(te.getTerritoryName());
        }

        // 状态
        TSType tp =
            systemService.getType(
                p.getStatus() == null ? null : p.getStatus().toString(), SystemType.TERMINAL_STATE);
        if (tp != null) {
          p.setStatusname(tp.getTypename());
        }

        pages.add(p);
      }

      TSUser user = ResourceUtil.getSessionUserName();
      workbook =
          ExcelExportUtil.exportExcel(
              new ExcelTitle("终端状态", "导出人:" + user.getRealName(), "导出信息"),
              TerminalInfoPage.class,
              pages);
      fOut = response.getOutputStream();
      workbook.write(fOut);
    } catch (Exception e) {
    } finally {
      try {
        fOut.flush();
        fOut.close();
      } catch (IOException e) {

      }
    }
  }
Esempio n. 9
0
  /**
   * @Title: myWorkTaskData @Description: TODO
   *
   * @param request
   * @param response
   * @param dataGrid void
   * @throws
   * @exception
   * @author fly
   * @date 2015年6月23日 上午10:20:42
   */
  @RequestMapping(params = "myWorkTaskData")
  public void myWorkTaskData(
      HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {

    String userId = ResourceUtil.getSessionUserName().getId();
    // involvedUser 当前用户相关的
    HistoricProcessInstanceQuery query =
        historyService.createHistoricProcessInstanceQuery().involvedUser(userId);

    List<HistoricProcessInstance> historicTasks =
        query
            .orderByProcessInstanceStartTime()
            .desc()
            .listPage(dataGrid.getStart(), dataGrid.getEnd());
    long total = query.count();
    System.out.println(dataGrid.getStart() + " end: " + dataGrid.getEnd());
    StringBuffer rows = new StringBuffer();
    for (HistoricProcessInstance t : historicTasks) {
      ProcessDefinition processDefinition =
          repositoryService.getProcessDefinition(t.getProcessDefinitionId());

      rows.append(
          "{'id':'"
              + t.getId()
              + "','key':'"
              + processDefinition.getName()
              + "-"
              + DateUtils.date_sdf.format(t.getStartTime())
              + "','taskId':'"
              + t.getId()
              + "'");
      // 流程详细查看
      WorkFlowSetEntity workFlowSet =
          systemService.findUniqueByProperty(
              WorkFlowSetEntity.class, "deploymentId", processDefinition.getDeploymentId());
      if (workFlowSet != null) {
        rows.append(",'action':'" + workFlowSet.getDetailUrl() + "'");
      }
      // 流程用户处理
      if (t.getStartUserId() != null) {
        TSUser user = systemService.get(TSUser.class, t.getStartUserId());
        rows.append(",'username':'******'");
      }

      // 流程开始结束时间处理
      if (t.getStartTime() == null) {
        rows.append(",'beginDate':'无'");
      } else {
        rows.append(",'beginDate':'" + DateUtils.datetimeFormat.format(t.getStartTime()) + "'");
      }
      if (t.getEndTime() == null) {
        rows.append(",'endDate':'无','stateType':'办理中'");

      } else {
        rows.append(
            ",'endDate':'"
                + DateUtils.datetimeFormat.format(t.getEndTime())
                + "','stateType':'已完成'");
      }
      rows.append("},");
    }
    String rowStr = StringUtils.substringBeforeLast(rows.toString(), ",");

    JSONObject jObject = JSONObject.fromObject("{'total':" + total + ",'rows':[" + rowStr + "]}");
    responseDatagrid(response, jObject);
  }