Пример #1
0
  public void saveUserDelegationInfo(Map<String, Object> params) {
    String addInfo = StringUtil.getString(params.get("add"));
    String updateInfo = StringUtil.getString(params.get("update"));
    String deleteInfo = StringUtil.getString(params.get("delete"));

    String agentUser = StringUtil.getString(params.get("agentUser"));
    String agentId = StringUtil.getString(params.get("agentId"));
    String startTime = StringUtil.getString(params.get("startTime"));
    String endTime = StringUtil.getString(params.get("endTime"));
    String status = StringUtil.getString(params.get("status"));

    if (StringUtil.isNotEmpty(agentUser)) {

      AgentEntity agentEntity = new AgentEntity();
      agentEntity.setAgentFrom(agentUser);
      agentEntity.setStatus(status);
      agentEntity.setId(agentId);
      if (StringUtil.isNotEmpty(startTime)) {
        agentEntity.setStartTime(DateUtil.stringToyyyyMmDdDate(startTime));
      }
      if (StringUtil.isNotEmpty(endTime)) {
        agentEntity.setEndTime(DateUtil.stringToyyyyMmDdDate(endTime));
      }

      // 代理id为空说明是新增
      if (StringUtil.isEmpty(agentId)) {
        agentEntity.setId(GuidUtil.CreateGuid());
        identityService.addAgent(agentEntity);
      } else {
        identityService.updateAgentEntity(agentEntity);
      }

      // 新增
      if (StringUtil.isNotEmpty(addInfo)) {
        Map<String, Object> agentInfo = JSONUtil.parseJSON2Map(addInfo);
        Iterator<String> iterator = agentInfo.keySet().iterator();
        String key = null;
        AgentDetailsEntity agentDetailsEntity = null;
        while (iterator.hasNext()) {
          key = iterator.next();
          agentDetailsEntity = new AgentDetailsEntity();
          agentDetailsEntity.setId(GuidUtil.CreateGuid());
          agentDetailsEntity.setAgentId(agentEntity.getId());
          agentDetailsEntity.setAgentTo(StringUtil.getString(agentInfo.get(key)));
          agentDetailsEntity.setProcessKey(key);
          identityService.addAgentDetails(agentDetailsEntity);
        }
      }
      // 更新
      if (StringUtil.isNotEmpty(updateInfo)) {
        Map<String, Object> agentInfo = JSONUtil.parseJSON2Map(updateInfo);
        Iterator<String> iterator = agentInfo.keySet().iterator();
        String key = null;
        Map<String, String> value = null;
        AgentDetailsEntity agentDetailsEntity = null;
        while (iterator.hasNext()) {
          key = iterator.next();
          value = (Map<String, String>) agentInfo.get(key);
          agentDetailsEntity = new AgentDetailsEntity();
          agentDetailsEntity.setId(key);
          agentDetailsEntity.setAgentId(agentEntity.getId());
          agentDetailsEntity.setAgentTo(value.get("user"));
          agentDetailsEntity.setProcessKey(value.get("key"));
          identityService.updateAgentDetailsEntity(agentDetailsEntity);
        }
      }
      // 删除
      if (StringUtil.isNotEmpty(deleteInfo)) {
        StringTokenizer st = new StringTokenizer(deleteInfo, ",");
        while (st.hasMoreTokens()) {
          identityService.deleteAgentDetails(st.nextToken());
        }
      }
    }
  }
Пример #2
0
  /**
   * 查询所有流程实例信息
   *
   * @param pageInfor 分页对象
   * @param params 查询条件参数
   * @return 返回查询结果
   * @throws FoxbpmWebException
   */
  public List<Map<String, Object>> queryProcessInst(
      Pagination<String> pageInfor, Map<String, Object> params) throws FoxbpmWebException {
    // 返回结果
    List<Map<String, Object>> resultData = new ArrayList<Map<String, Object>>();
    ProcessInstanceQuery piq = runtimeService.createProcessInstanceQuery();
    // 获取查询条件参数
    String userId = StringUtil.getString(params.get("userId"));
    String processDefinitionKey = StringUtil.getString(params.get("processDefinitionKey"));
    String processInstanceId = StringUtil.getString(params.get("processInstanceId"));
    String processDefinitionName = StringUtil.getString(params.get("processDefinitionName"));
    String title = StringUtil.getString(params.get("title"));
    String bizKey = StringUtil.getString(params.get("bizKey"));
    String initor = StringUtil.getString(params.get("initor"));
    String status = StringUtil.getString(params.get("status"));
    String processType = StringUtil.getString(params.get("processType"));

    String dss = StringUtil.getString(params.get("startTimeS"));
    String dse = StringUtil.getString(params.get("startTimeE"));
    if (StringUtil.isNotEmpty(processDefinitionKey)) {
      piq.processDefinitionKey(processDefinitionKey);
    }
    if (StringUtil.isNotEmpty(processInstanceId)) {
      piq.processInstanceId(processInstanceId);
    }
    if (StringUtil.isNotEmpty(title)) {
      piq.subjectLike(assembleLikeParam(title));
    }
    if (StringUtil.isNotEmpty(bizKey)) {
      piq.processInstanceBusinessKeyLike(assembleLikeParam(bizKey));
    }
    if (StringUtil.isNotEmpty(status)) {
      piq.processInstanceStatus(status);
    }

    if (StringUtil.isNotEmpty(initor)) {
      piq.initiator(initor);
    }

    if (StringUtil.isNotEmpty(processType)) {
      if (processType.equals("initor")) {
        piq.initiator(userId);
      } else {
        piq.taskParticipants(userId);
      }
    }
    if (StringUtil.isNotEmpty(processDefinitionName)) {
      piq.processDefinitionNameLike(assembleLikeParam(processDefinitionName));
    }
    Date dates = null;
    Date datee = null;

    if (StringUtil.isNotEmpty(dss)) {
      dates = DateUtil.stringToDate(dss, "yyyy-MM-dd");
    }
    if (StringUtil.isNotEmpty(dse)) {
      String endTime = "235959999";
      dse += endTime;
      datee = DateUtil.stringToDate(dse, "yyyy-MM-ddHHmmssSSS");
    }
    if (null != dates) {
      piq.startTimeBefore(dates);
    }
    if (null != datee) {
      piq.startTimeAfter(datee);
    }

    List<ProcessInstance> piList = null;
    piq.orderByUpdateTime().desc();
    if (null == pageInfor) {
      piList = piq.list();
    } else {
      // 执行分页查询
      piList = piq.listPagination(pageInfor.getPageIndex(), pageInfor.getPageSize());
      // 设置分页信息
      pageInfor.setTotal(StringUtil.getInt(piq.count()));
    }
    // 流程实例属性集
    Map<String, Object> attrMap = null;
    ProcessInstance pi = null;
    for (int i = 0, size = (null == piList) ? 0 : piList.size(); i < size; i++) {
      pi = piList.get(i);
      attrMap = pi.getPersistentState();
      attrMap.put(
          "processDefinitionName",
          modelService.getProcessDefinition(pi.getProcessDefinitionId()).getName());
      attrMap.put("initiatorName", getUserName(StringUtil.getString(attrMap.get("initiator"))));
      resultData.add(attrMap);
    }

    return resultData;
  }