protected List<ProcessInstance> fetchProcessInstancesPage(
     CommandContext commandContext,
     ProcessDefinition processDefinition,
     int currentPageStartIndex) {
   if (SuspensionState.ACTIVE.equals(getProcessDefinitionSuspensionState())) {
     return new ProcessInstanceQueryImpl(commandContext)
         .processDefinitionId(processDefinition.getId())
         .suspended()
         .listPage(
             currentPageStartIndex,
             Context.getProcessEngineConfiguration().getBatchSizeProcessInstances());
   } else {
     return new ProcessInstanceQueryImpl(commandContext)
         .processDefinitionId(processDefinition.getId())
         .active()
         .listPage(
             currentPageStartIndex,
             Context.getProcessEngineConfiguration().getBatchSizeProcessInstances());
   }
 }
Esempio n. 2
0
public class MyTask {
  private int revision;
  private String id;

  private String owner;
  private String assignee;
  private DelegationState delegationState;

  private String parentTaskId;

  private String name;
  private String description;
  private Date createTime; // The time when the task has been created
  private Date dueDate;
  private int suspensionState = SuspensionState.ACTIVE.getStateCode();

  private boolean isIdentityLinksInitialized = false;
  private List<IdentityLinkEntity> taskIdentityLinkEntities = new ArrayList<IdentityLinkEntity>();

  private String executionId;
  private ExecutionEntity execution;

  private String processInstanceId;
  private ExecutionEntity processInstance;

  private String processDefinitionId;

  private TaskDefinition taskDefinition;
  private String taskDefinitionKey;

  private boolean isDeleted;

  private String eventName;

  public int getRevision() {
    return revision;
  }

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public void setRevision(int revision) {
    this.revision = revision;
  }

  public String getOwner() {
    return owner;
  }

  public void setOwner(String owner) {
    this.owner = owner;
  }

  public String getAssignee() {
    return assignee;
  }

  public void setAssignee(String assignee) {
    this.assignee = assignee;
  }

  public DelegationState getDelegationState() {
    return delegationState;
  }

  public void setDelegationState(DelegationState delegationState) {
    this.delegationState = delegationState;
  }

  public String getParentTaskId() {
    return parentTaskId;
  }

  public void setParentTaskId(String parentTaskId) {
    this.parentTaskId = parentTaskId;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public Date getCreateTime() {
    return createTime;
  }

  public void setCreateTime(Date createTime) {
    this.createTime = createTime;
  }

  public Date getDueDate() {
    return dueDate;
  }

  public void setDueDate(Date dueDate) {
    this.dueDate = dueDate;
  }

  public int getSuspensionState() {
    return suspensionState;
  }

  public void setSuspensionState(int suspensionState) {
    this.suspensionState = suspensionState;
  }

  public boolean isIdentityLinksInitialized() {
    return isIdentityLinksInitialized;
  }

  public void setIdentityLinksInitialized(boolean isIdentityLinksInitialized) {
    this.isIdentityLinksInitialized = isIdentityLinksInitialized;
  }

  public List<IdentityLinkEntity> getTaskIdentityLinkEntities() {
    return taskIdentityLinkEntities;
  }

  public void setTaskIdentityLinkEntities(List<IdentityLinkEntity> taskIdentityLinkEntities) {
    this.taskIdentityLinkEntities = taskIdentityLinkEntities;
  }

  public String getExecutionId() {
    return executionId;
  }

  public void setExecutionId(String executionId) {
    this.executionId = executionId;
  }

  public ExecutionEntity getExecution() {
    return execution;
  }

  public void setExecution(ExecutionEntity execution) {
    this.execution = execution;
  }

  public String getProcessInstanceId() {
    return processInstanceId;
  }

  public void setProcessInstanceId(String processInstanceId) {
    this.processInstanceId = processInstanceId;
  }

  public ExecutionEntity getProcessInstance() {
    return processInstance;
  }

  public void setProcessInstance(ExecutionEntity processInstance) {
    this.processInstance = processInstance;
  }

  public String getProcessDefinitionId() {
    return processDefinitionId;
  }

  public void setProcessDefinitionId(String processDefinitionId) {
    this.processDefinitionId = processDefinitionId;
  }

  public TaskDefinition getTaskDefinition() {
    return taskDefinition;
  }

  public void setTaskDefinition(TaskDefinition taskDefinition) {
    this.taskDefinition = taskDefinition;
  }

  public String getTaskDefinitionKey() {
    return taskDefinitionKey;
  }

  public void setTaskDefinitionKey(String taskDefinitionKey) {
    this.taskDefinitionKey = taskDefinitionKey;
  }

  public boolean isDeleted() {
    return isDeleted;
  }

  public void setDeleted(boolean isDeleted) {
    this.isDeleted = isDeleted;
  }

  public String getEventName() {
    return eventName;
  }

  public void setEventName(String eventName) {
    this.eventName = eventName;
  }
}
  public boolean requestServiceCertificateValidate(Long id, String carManEntryKey, Json json) {
    Assert.assertNotNull(id);
    Assert.assertNotNull(carManEntryKey);
    Assert.assertNotNull(json);

    TempDriver driver = this.tempDriverDao.load(id);

    // 不存在流程关系
    if (!this.workflowModuleRelationService.hasRelation4Key(
        id, TempDriver.WORKFLOW_MTYPE, carManEntryKey)) return false;
    // 声明变量
    String _true = "1";

    // 设置需要获取的变量
    String[] args =
        new String[] {"isGiveUp", "isPass", "isPairDriver", "pairDriverName", "pairDriverNameId"};
    // 复试组组长任务key
    String taskKey = "t100RetestHeadCheck";
    // 本地变量
    String localKey = "isPass_lc";

    // 获取最新的司机入职流程相关参数
    Map<String, Object> driver_wf =
        this.workflowModuleRelationService
            .findList(id, TempDriver.WORKFLOW_MTYPE, carManEntryKey, args)
            .get(0);
    // 流程id
    String pid = driver_wf.get("pid").toString();
    // 流程状态
    int pStatus = Integer.valueOf(driver_wf.get("status").toString());
    // 查找复试组长是否选择通过变量
    Object pass_lc = this.workflowService.findLocalValue(pid, taskKey, localKey);
    // 复试组长 选项                                流程未到复试组长组长审批                 选择不通过
    boolean isPass_lc = _true.equals(pass_lc);
    // 不具备发起的条件
    // 流程未结束,(流程未到复试组长组长审批或复试组组长选择不通过)
    if (SuspensionState.ACTIVE.getStateCode() == pStatus && !isPass_lc) return false;

    // 司机放弃入职变量
    boolean isGiveUp = _true.equals(driver_wf.get("isGiveUp"));
    // 司机通过入职变量
    boolean isPass = _true.equals(driver_wf.get("isPass"));
    // 是否有对班司机编辑
    boolean isPair = _true.equals(driver_wf.get("isPairDriver"));

    // 无论是否有对班司机 ,都不具备发起的条件
    // 流程结束,司机选择放弃
    if (WorkspaceServiceImpl.COMPLETE == pStatus && isGiveUp) return false;
    // 流程结束,司机不通过
    if (WorkspaceServiceImpl.COMPLETE == pStatus && !isPass) return false;

    // 设置司机信息
    json.put("id", id.toString());
    json.put("name", driver.getName());
    json.put("applyAttr", driver.getApplyAttr()); // 申请属性
    // 设置对班司机的身份证很从业资格证
    json.put("certIdentity", driver.getCertIdentity());
    json.put("certCYZG", driver.getCertCYZG());
    json.put("pid", pid);
    json.put("pname", driver_wf.get("name").toString());
    // 设置是否有对班 默认没有
    json.put("isPairDriver", false);

    // 没有对班,司机具备发起服务资格证流程条件
    // 流程结束  &&没有放弃 &&入职通过
    if (!isPair && WorkspaceServiceImpl.COMPLETE == pStatus && !isGiveUp && isPass) return true;
    // 流程未结束 && 复试组组长选择通过
    if (!isPair && SuspensionState.ACTIVE.getStateCode() == pStatus && isPass_lc) return true;

    // ******存在对班 查找对班的入职情况***开始****
    // 对班id
    Long pDriverId = Long.valueOf(driver_wf.get("pairDriverNameId").toString());
    TempDriver pDriver = this.tempDriverDao.load(pDriverId);
    json.put("isPairDriver", true);

    // 对班存在入职流程
    if (this.workflowModuleRelationService.hasRelation4Key(
        pDriverId, TempDriver.WORKFLOW_MTYPE, carManEntryKey)) {
      // 获取对班司机最新的司机入职流程相关参数
      Map<String, Object> pDriver_wf =
          this.workflowModuleRelationService
              .findList(pDriverId, TempDriver.WORKFLOW_MTYPE, carManEntryKey, args)
              .get(0);
      // 流程id
      String pDriver_pid = pDriver_wf.get("pid").toString();
      // 司机放弃入职变量
      boolean pDriver_isGiveUp = _true.equals(pDriver_wf.get("isGiveUp"));
      // 司机通过入职变量
      boolean pDriver_isPass = _true.equals(pDriver_wf.get("isPass"));
      // 是否有对班司机编辑
      boolean pDriver_isPair = _true.equals(pDriver_wf.get("isPairDriver"));
      // 流程状态
      int pDriver_pStatus = Integer.valueOf(pDriver_wf.get("status").toString());
      // 查找复试组长是否选择通过变量
      Object pDriver_pass_lc = this.workflowService.findLocalValue(pDriver_pid, taskKey, localKey);
      // 复试组长 选项                                                              流程未到复试组长组长审批
      // 选择不通过
      boolean pDriver_isPass_lc = _true.equals(pDriver_pass_lc);

      // 司机和对班都具备发起服务资格证流程的条件
      if ( // 条件1)流程结束  &&没有放弃 &&入职通过  && 有对班
      (WorkspaceServiceImpl.COMPLETE == pDriver_pStatus
              && !pDriver_isGiveUp
              && pDriver_isPass
              && pDriver_isPair)
          // 条件2)流程未结束 && 复试组组长选择通过 && 有对班
          || (SuspensionState.ACTIVE.getStateCode() == pDriver_pStatus
              && pDriver_isPass_lc
              && pDriver_isPair)) {
        // 设置对班司机信息
        json.put("pair_id", pDriverId.toString());
        json.put("pair_name", pDriver.getName());
        json.put("pair_applyAttr", pDriver.getApplyAttr()); // 申请属性
        // 设置对班司机的身份证很从业资格证
        json.put("pair_certIdentity", pDriver.getCertIdentity());
        json.put("pair_certCYZG", pDriver.getCertCYZG());
        json.put("pair_pid", pDriver_pid);
        json.put("pair_pname", pDriver_wf.get("name").toString());
        return true;
      }
    }
    // ******存在对班 查找对班的入职情况***结束****

    // ****查找对班但未符合发起的条件,入职通过的司机再找另外一个对班司机的情况****开始*****
    List<Map<String, Object>> others =
        this.workflowModuleRelationService.findList(
            null,
            TempDriver.WORKFLOW_MTYPE,
            carManEntryKey,
            new String[] {
              "isGiveUp",
              "isPass",
              "isPairDriver",
              "pairDriverName",
              "pairDriverNameId",
              "tempDriver_id"
            });

    for (Map<String, Object> wmr : others) {
      if (_true.equals(wmr.get("isPairDriver")) // 有选择对班
          // 选择原通过的司机
          && String.valueOf(id).equals(wmr.get("pairDriverNameId"))) {
        // 流程id
        String new_pid = wmr.get("pid").toString();
        // 司机放弃入职变量
        boolean new_isGiveUp = _true.equals(wmr.get("isGiveUp"));
        // 司机通过入职变量
        boolean new_isPass = _true.equals(wmr.get("isPass"));
        // 流程状态
        int new_pStatus = Integer.valueOf(wmr.get("status").toString());

        // 查找复试组长是否选择通过变量
        Object new_pass_lc = this.workflowService.findLocalValue(new_pid, taskKey, localKey);
        // 复试组长 选项                                                   流程未到复试组长组长审批
        //       选择不通过
        boolean new_isPass_lc = _true.equals(new_pass_lc);

        // 新的对班司机
        TempDriver newPairDriver =
            this.tempDriverDao.load(Long.valueOf(wmr.get("tempDriver_id").toString()));

        // 司机和新的对班都具备发起服务资格证流程的条件
        if ( // 条件1)流程结束  &&没有放弃 &&入职通过
        (WorkspaceServiceImpl.COMPLETE == new_pStatus && !new_isGiveUp && new_isPass)
            // 条件2)流程未结束 && 复试组组长选择通过
            || (SuspensionState.ACTIVE.getStateCode() == new_pStatus && new_isPass_lc)) {
          // 设置对班司机信息
          json.put("pair_id", newPairDriver.getId().toString());
          json.put("pair_name", newPairDriver.getName());
          json.put("pair_applyAttr", newPairDriver.getApplyAttr()); // 申请属性
          // 设置对班司机的身份证很从业资格证
          json.put("pair_certIdentity", newPairDriver.getCertIdentity());
          json.put("pair_certCYZG", newPairDriver.getCertCYZG());
          json.put("pair_pid", new_pid);
          json.put("pair_pname", wmr.get("name").toString());
          return true;
        }
      }
    }
    // ****查找对班但未符合发起的条件,入职通过的司机再找另外一个对班司机的情况****结束*****

    return false;
  }