示例#1
0
  @Transactional(readOnly = false)
  public void delegateMain() {
    try {
      // 权限委托
      List<TrustRecord> delegateMains = delegateMainManager.getDelegateMainsOnAssign();
      for (TrustRecord dm : delegateMains) {
        com.norteksoft.product.api.entity.User trustee =
            ApiFactory.getAcsService().getUserByLoginName(dm.getTrustee()); // 受托人
        com.norteksoft.product.api.entity.User trustor =
            ApiFactory.getAcsService().getUserByLoginName(dm.getTrustor()); // 委托人
        if (needEfficient(dm)) {
          ApiFactory.getAcsService()
              .assignTrustedRole(trustor.getId(), dm.getRoleIds().split(","), trustee.getId());
          dm.setState(TrustRecordState.EFFICIENT);
          delegateMainManager.saveDelegateMain(dm);
        }
        if (needEnd(dm)) {
          ApiFactory.getAcsService()
              .deleteTrustedRole(trustor.getId(), dm.getRoleIds().split(","), trustee.getId());
          dm.setState(TrustRecordState.END);
          delegateMainManager.saveDelegateMain(dm);
        }
      }

      // 流程委托
      List<TrustRecord> workflowDelegateMains =
          delegateMainManager.getAllStartWorkflowDelegateMain();
      for (TrustRecord wfdm : workflowDelegateMains) {
        if (needEfficient(wfdm)) {
          wfdm.setState(TrustRecordState.EFFICIENT);
          delegateMainManager.saveDelegateMain(wfdm);
        }
        if (needEnd(wfdm)) {
          wfdm.setState(TrustRecordState.END);
          delegateMainManager.saveDelegateMain(wfdm);
          // 委托结束时取回任务
          taskService.recieveDelegateTask(wfdm);
        }
      }
    } catch (Exception e) {
      log.error("定时委托异常:" + e.getMessage());
    }
  }
示例#2
0
 /*
  * 判断是需要生效
  * 当委托处于启用状态,并且当前日期在生效日期和截至日期之间时就需要生效
  */
 public boolean needEfficient(TrustRecord dm) {
   return dm.getState() == TrustRecordState.STARTED
       && dm.getBeginTime().compareTo(new Date(System.currentTimeMillis())) <= 0
       && dm.getEndTime().compareTo(new Date(System.currentTimeMillis())) >= 0;
 }
示例#3
0
 /*
  * 判断是需要结束委托
  * 当委托处于生效状态,并且当前日期大于或等于截至日期时就需要结束
  */
 public boolean needEnd(TrustRecord dm) {
   return (dm.getState() == TrustRecordState.EFFICIENT
           || dm.getState() == TrustRecordState.STARTED)
       && dm.getEndTime().compareTo(new Date(System.currentTimeMillis())) <= 0;
 }