예제 #1
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);
 }
예제 #2
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);
 }