Пример #1
0
  @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);
  }
Пример #2
0
 /**
  * 一键授权功能
  *
  * @param request
  * @param response
  * @throws IOException
  * @throws AesException
  * @throws DocumentException
  */
 @RequestMapping(value = "/goAuthor")
 public void goAuthor(HttpServletRequest request, HttpServletResponse response)
     throws IOException, AesException, DocumentException {
   ApiComponentToken apiComponentToken = new ApiComponentToken();
   apiComponentToken.setComponent_appid(COMPONENT_APPID);
   apiComponentToken.setComponent_appsecret(COMPONENT_APPSECRET);
   WeixinOpenAccountEntity entity = getWeixinOpenAccount(APPID);
   apiComponentToken.setComponent_verify_ticket(entity.getTicket());
   try {
     String component_access_token = JwThirdAPI.getAccessToken(apiComponentToken);
     // 预授权码
     String preAuthCode = JwThirdAPI.getPreAuthCode(COMPONENT_APPID, component_access_token);
     String url =
         "https://mp.weixin.qq.com/cgi-bin/componentloginpage?component_appid="
             + COMPONENT_APPID
             + "&pre_auth_code="
             + preAuthCode
             + "&redirect_uri="
             + ResourceUtil.getConfigByName("domain")
             + "/rest/openwx/authorCallback";
     response.sendRedirect(url);
   } catch (WexinReqException e) {
     e.printStackTrace();
   }
 }
Пример #3
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);
  }
Пример #4
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);
  }
 public <T> Serializable save(T entity) {
   MenuEntity menuEntity = (MenuEntity) entity;
   menuEntity.setAccountId(ResourceUtil.getWeiXinAccountId());
   Serializable t = super.save(entity);
   // 执行新增操作配置的sql增强
   this.doAddSql((MenuEntity) entity);
   return t;
 }
Пример #6
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) {

      }
    }
  }
 /**
  * 添加扩展接口管理
  *
  * @param ids
  * @return
  */
 @RequestMapping(params = "doAdd")
 @ResponseBody
 public AjaxJson doAdd(WeixinExpandconfigEntity weixinExpandconfig, HttpServletRequest request) {
   AjaxJson j = new AjaxJson();
   message = "扩展接口管理添加成功";
   try {
     weixinExpandconfig.setAccountid(ResourceUtil.getWeiXinAccountId());
     weixinExpandconfigService.save(weixinExpandconfig);
     systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
   } catch (Exception e) {
     e.printStackTrace();
     message = "扩展接口管理添加失败";
     throw new BusinessException(e.getMessage());
   }
   j.setMsg(message);
   return j;
 }
 /**
  * easyui AJAX请求数据
  *
  * @param request
  * @param response
  * @param dataGrid
  * @param user
  */
 @RequestMapping(params = "datagrid")
 public void datagrid(
     WeixinCmsSiteEntity weixinCmsSite,
     HttpServletRequest request,
     HttpServletResponse response,
     DataGrid dataGrid) {
   CriteriaQuery cq = new CriteriaQuery(WeixinCmsSiteEntity.class, dataGrid);
   // 查询条件组装器
   org.jeecgframework.core.extend.hqlsearch.HqlGenerateUtil.installHql(
       cq, weixinCmsSite, request.getParameterMap());
   cq.eq(ACCOUNTID, ResourceUtil.getWeiXinAccountId());
   try {
     // 自定义追加查询条件
   } catch (Exception e) {
     throw new BusinessException(e.getMessage());
   }
   cq.add();
   this.weixinCmsSiteService.getDataGridReturn(cq, true);
   TagUtil.datagrid(response, dataGrid);
 }
  /**
   * 导出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) {

      }
    }
  }
Пример #11
0
  @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);
  }
 /**
  * 添加微站点信息
  *
  * @param ids
  * @return
  */
 @RequestMapping(params = "doAdd")
 @ResponseBody
 public AjaxJson doAdd(WeixinCmsSiteEntity weixinCmsSite, HttpServletRequest request) {
   AjaxJson j = new AjaxJson();
   List lst =
       weixinCmsSiteService.findByProperty(
           WeixinCmsSiteEntity.class, "accountid", ResourceUtil.getWeiXinAccountId());
   if (lst.size() != 0) {
     message = "每个用户只能添加一个微信站点";
     j.setSuccess(false);
   } else {
     message = "微站点信息添加成功";
     try {
       weixinCmsSiteService.save(weixinCmsSite);
       systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
     } catch (Exception e) {
       e.printStackTrace();
       message = "微站点信息添加失败";
       throw new BusinessException(e.getMessage());
     }
   }
   j.setMsg(message);
   return j;
 }
  /**
   * 导出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) {

      }
    }
  }
Пример #14
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);
  }