Ejemplo n.º 1
0
  public void renewAwt(
      WfAwt prev, WfTask currtask, WfTask nextTask, TaskOptVO optVO, String currUserId)
      throws BusinessException {
    if (nextTask != null && WFConstants.TaskTypes.E.getTypeCode().equals(nextTask.getTaskType())) {
      optVO.setNextEndTaskFlag(true);
    } else {
      optVO.setNextEndTaskFlag(false);
    }
    WfInstance wfInst = instService.selectById(prev.getInstId());

    String optCode = optVO.getOptCode();
    boolean needNextStep = false;
    switch (optCode) {
      case WFConstants.OptTypes.COMMIT:
        needNextStep = renew4Commit(prev, currtask, wfInst, currUserId);
        break;
      case WFConstants.OptTypes.REJECT:
        needNextStep = renewReject();
        break;
      case WFConstants.OptTypes.FORWARD:
        needNextStep = renew4Forward(wfInst, optVO, currUserId);
        break;
      case WFConstants.OptTypes.LET_ME_DO:
        needNextStep = renew4LetMeDo(wfInst, currtask, currUserId);
        break;
      case WFConstants.OptTypes.RECALL:
        needNextStep = renewRecall(wfInst, nextTask, currUserId);
        break;
      default:
        break;
    }
    if (needNextStep) {
      clearAwtUpdateInstGoNextStep(wfInst, optVO, nextTask, currUserId);
    }
  }
Ejemplo n.º 2
0
 /**
  * Clear Current Awt, update Instance. Go next step: insert new Awt if needed.
  *
  * @param wfInst
  * @param optVO
  * @param nextTask
  */
 private void clearAwtUpdateInstGoNextStep(
     WfInstance wfInst, TaskOptVO optVO, WfTask nextTask, String currUserId) {
   String optdUsers = wfInst.getOptUsersPre();
   if (StringUtils.isEmpty(optdUsers)) {
     wfInst.setOptUsersPre(currUserId + ",");
   } else {
     if (!optdUsers.contains(currUserId)) {
       wfInst.setOptUsersPre(optdUsers + currUserId + ",");
     }
   }
   String instId = wfInst.getInstId();
   WfAwt parm = new WfAwt();
   parm.setInstId(instId);
   parm.setCompleteFlag(null);
   this.deleteSelective(parm);
   // create new awt(s) with next taskId
   String nextAssigners = optVO.getNextAssigners();
   if (nextAssigners != null && !optVO.isNextEndTaskFlag()) {
     String[] nextAssignersArr = nextAssigners.split(",");
     WfAwt awt = null;
     Date beginDate = new Date();
     Date limitDate = calculateDate(beginDate, nextTask.getTimeLimitTp(), nextTask.getTimeLimit());
     Date alarmDate =
         nextTask.getAlarmTime() == null
             ? null
             : calculateDate(beginDate, nextTask.getAlarmTimeTp(), nextTask.getAlarmTime());
     String optUsersPre = wfInst.getOptUsersPre();
     if (optUsersPre != null && optUsersPre.indexOf(",") == optUsersPre.length() - 1) {
       optUsersPre = optUsersPre.substring(0, optUsersPre.length() - 1);
     }
     for (String assigner : nextAssignersArr) {
       if (!StringUtils.isEmpty(assigner)) {
         awt = new WfAwt();
         /** 当任务流转到下一个节点,下一个节点的awt数据:设置optUsersPre&taskIdPre */
         awt.setOptUsersPre(optUsersPre);
         awt.setTaskIdPre(wfInst.getTaskIdCurr());
         awt.setAssignerId(assigner);
         awt.setAwtBegin(beginDate);
         awt.setAwtEnd(limitDate);
         awt.setAwtAlarm(alarmDate);
         awt.setInstId(instId);
         awt.setTaskIdCurr(optVO.getNextTaskId());
         this.insert(awt);
       }
     }
   }
   /** 当事务流转到下一个节点时,重置currTaskid&optdUsers 为上一步操作人(可能是多个)和上一个任务节点 */
   wfInst.setCurrAssigners(nextAssigners);
   wfInst.setTaskIdPre(wfInst.getTaskIdCurr());
   wfInst.setTaskIdCurr(nextTask.getTaskId());
   if (optVO.isNextEndTaskFlag()) {
     wfInst.setWfStatus(WFConstants.WFStatus.DONE);
   }
   instService.updateById(wfInst);
 }
Ejemplo n.º 3
0
  private boolean renew4Forward(WfInstance wfInst, TaskOptVO optVO, String currUserId)
      throws BusinessException {
    WfAwt awtParm = new WfAwt();
    awtParm.setInstId(wfInst.getInstId());
    awtParm.setAssignerId(currUserId);
    WfAwt awt = this.selectOne(awtParm);
    if (awt == null) {
      log.error(
          "renew4Forward(): no awt found for instId="
              + wfInst.getInstId()
              + ", currUserid="
              + currUserId);
      return false;
    }

    String nextAssigners = optVO.getNextAssigners();
    String currAssigners = wfInst.getCurrAssigners();
    wfInst.setCurrAssigners(currAssigners.replace(currUserId + ",", nextAssigners + ","));
    String optdUsers = wfInst.getOptUsersPre();
    if (optdUsers != null && optdUsers.contains(currUserId)) {
      wfInst.setOptUsersPre(optdUsers.replace(currUserId + ",", ""));
    }
    instService.updateById(wfInst);

    String[] nextAssignerArray = nextAssigners.split(",");
    WfAwt awtNew = null;
    List<WfAwt> awtNewList = new ArrayList<WfAwt>(nextAssignerArray.length);
    try {
      for (String assinger : nextAssignerArray) {
        if (!StringUtils.isEmpty(assinger)) {
          awtParm.setAssignerId(assinger);
          awtNew = this.selectOne(awtParm);
          if (awtNew != null) {
            continue;
          }
          awtNew = awt.clone();
          awtNew.setAssignerId(assinger);
          awtNew.setOptUsersPre(currUserId);
          awtNew.setTaskIdPre(awt.getTaskIdCurr());
          awtNew.setWfAwtId(null);
          awtNewList.add(awtNew);
        }
      }
    } catch (CloneNotSupportedException e) {
      log.error("renew4Forward(): CloneNotSupportedException ", e);
      throw new BusinessException("Error when create Awt for forward task");
    }
    this.deleteById(awt.getWfAwtId());
    if (!awtNewList.isEmpty()) {
      this.insertBatch(awtNewList);
    }
    return false;
  }
Ejemplo n.º 4
0
 private void removeUserFromOptUserPrev(
     WfInstance wfInst, String currUserId, String currTaskId, boolean refreshCurrAssigners) {
   String optdUsers = wfInst.getOptUsersPre();
   if (optdUsers != null && optdUsers.contains(currUserId)) {
     wfInst.setOptUsersPre(optdUsers.replace(currUserId + ",", ""));
   }
   String currAssigners = wfInst.getCurrAssigners();
   if (currAssigners == null || refreshCurrAssigners) {
     currAssigners = currUserId + ",";
   } else {
     currAssigners += currUserId;
   }
   wfInst.setCurrAssigners(currAssigners);
   wfInst.setTaskIdCurr(currTaskId);
   instService.updateById(wfInst);
 }
Ejemplo n.º 5
0
 private void updateCurrAssigners4CS(WfInstance wfInst, String currUserId) {
   String optdUsers = wfInst.getOptUsersPre();
   if (optdUsers == null) {
     optdUsers = currUserId + ",";
   } else {
     if (!optdUsers.contains(currUserId)) {
       optdUsers += currUserId + ",";
     }
   }
   /** 事务未流转,更新该task的处理人 */
   wfInst.setOptUsersPre(optdUsers);
   String currAssigners4Inst = wfInst.getCurrAssigners();
   if (currAssigners4Inst != null) {
     if (currAssigners4Inst.contains(currUserId + ",")) {
       wfInst.setCurrAssigners(currAssigners4Inst.replace(currUserId + ",", ""));
       instService.updateById(wfInst); // 更新当前处理人
       wfInst.setCurrAssigners(currAssigners4Inst);
     }
   }
 }