Beispiel #1
0
 /**
  * 环节跳转功能
  *
  * @return
  * @throws Exception
  */
 public String goback() throws Exception {
   String msg = "任务跳转成功";
   try {
     CompleteTaskTipType result = null;
     workflowInstance = workflowInstanceManager.getWorkflowInstance(workflowId);
     result = taskService.taskJump(workflowInstance, backto, transactors, null, false);
     switch (result) {
       case OK:
         msg = "OK";
         break;
       case RETURN_URL:
         msg = "RETURN_URL";
         break;
       case SINGLE_TRANSACTOR_CHOICE:
         User temp;
         for (String tran : result.getCanChoiceTransactor()) {
           temp = userManager.getUserByLoginName(tran);
           if (temp != null)
             canChoiceTransacators = canChoiceTransacators + tran + "," + temp.getName() + ";";
         }
         msg = "SINGLE_TRANSACTOR_CHOICE";
         break;
       case MESSAGE:
         msg = result.getContent();
     }
   } catch (Exception e) {
     PropUtils.getExceptionInfo(e);
     msg = "环节跳转失败";
   }
   ApiFactory.getBussinessLogService().log("流程监控", "执行环节跳转", ContextUtils.getSystemId("wf"));
   renderText(msg + "=" + canChoiceTransacators);
   return null;
 }
  /**
   * 保存工作组添加用户
   *
   * @return
   * @throws Exception
   */
  @Action("work-group-workgroupAddUser")
  public String workgroupAddUser() throws Exception {
    if (StringUtils.isNotEmpty(ids)) {
      userIds = new ArrayList<Long>();
      User user = userManager.getUserById(ContextUtils.getUserId());
      if ("ALLCOMPANYID".equals(ids)) { // 全公司
        userIds.add(0l);
      } else {
        if (roleManager.hasSystemAdminRole(user)) {
          for (String str : ids.split(",")) {
            userIds.add(Long.valueOf(str));
          }
        } else if (roleManager.hasBranchAdminRole(user)) {
          userIds = ApiFactory.getAcsService().getTreeUserIds(ids);
        }
      }

      String addUsers = workGroupManager.workgroupAddUser(workGroupId, userIds, 0);

      if (StringUtils.isNotEmpty(addUsers))
        ApiFactory.getBussinessLogService()
            .log("工作组管理", "工作组添加人员:" + addUsers, ContextUtils.getSystemId("acs"));
    }
    this.renderText("ok");
    return null;
  }
Beispiel #3
0
 public void emailReminder(WorkflowTask task) {
   User user = userManager.getUserByLoginName(task.getTransactor());
   String msg =
       new StringBuilder("任务:")
           .append(task.getTitle())
           .append("已经生成")
           .append(((System.currentTimeMillis() - task.getCreatedTime().getTime()) / MILLI_SECOND))
           .append("天了。请尽快办理!")
           .toString();
   AsyncMailUtils.sendMail(user.getEmail(), "催办超期提醒", msg);
 }
Beispiel #4
0
 public void emailInform(WorkflowTask task) {
   if (StringUtils.isNotEmpty(task.getReminderNoticeUser())) {
     Set<String> informUserEmails = new HashSet<String>();
     User temp;
     for (String userLoginName : task.getReminderNoticeUser().split(",")) {
       temp = userManager.getUserByLoginName(userLoginName);
       if (temp != null) informUserEmails.add(temp.getEmail());
     }
     String msg =
         new StringBuilder("任务:")
             .append(task.getTitle())
             .append("的办理人")
             .append(task.getTransactorName())
             .append("被催办次数已经超过设置上限,请您核实情况。")
             .toString();
     AsyncMailUtils.sendMail(informUserEmails, "催办超期提醒", msg);
   }
 }
Beispiel #5
0
 /** 指定办理人 */
 @Action(value = "taskassign")
 public String assignTransactor() throws Exception {
   String to = INPUT;
   if (task.getId() == null) {
     this.addErrorMessage("非法的任务");
   } else {
     WorkflowInstance instance =
         workflowInstanceManager.getWorkflowInstance(task.getProcessInstanceId());
     CompleteTaskTipType result = taskService.isNeedAssigningTransactor(instance, task);
     if (result == null) {
       result = taskService.isSubProcessNeedChoiceTransactor(task, instance);
     }
     switch (result) {
       case OK:
         this.addSuccessMessage(result.getContent());
         to = input();
         break;
       case MESSAGE:
         this.addErrorMessage(result.getContent());
         to = INPUT;
         break;
       case RETURN_URL:
         candidates = taskService.getNextTasksCandidates(task);
         this.addErrorMessage("请选择办理人");
         to = "assign";
         break;
       case TACHE_CHOICE_URL:
         addActionMessage("请选择环节");
         canChoiceTaches = result.getCanChoiceTaches();
         to = choiceTache();
       case SINGLE_TRANSACTOR_CHOICE:
         User temp;
         for (String tran : result.getCanChoiceTransactor()) {
           temp = userManager.getUserByLoginName(tran);
           if (temp != null) canChoiceTransactor.put(tran, temp.getName());
         }
         moreTransactor = CompleteTaskTipType.SINGLE_TRANSACTOR_CHOICE.getContent().equals("true");
         to = "singleTransactorChoice";
     }
   }
   ApiFactory.getBussinessLogService().log("工作流管理", "指定办理人", ContextUtils.getSystemId("wf"));
   return to;
 }
  public UserDetails loadUserByUsername(String loginName)
      throws UsernameNotFoundException, DataAccessException {
    log.debug("*** Received parameter: loginName:" + loginName);
    if (loginName.contains(
        "%")) { // 表示是swing“办公助手”中访问v1/tickets过来的,有%表示用户登录名或分支编码有中文,已进行编码URLEncoder.encode(username,
      // "utf-8"),需要解码
      try {
        loginName = URLDecoder.decode(loginName, "utf-8");
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
      }
    }
    // loginName的格式为loginName~~companyCode
    User user = userManager.getUserByLoginNameAndBranchCode(loginName);

    //		try {
    //			Map<String, String> licence = License.getLicense();
    //			String dateString = licence.get("end_time");
    //			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    //			Date settingDate = df.parse(dateString);
    //			Date date = userManager.getUserTs(user.getCompanyId());
    //			if(date != null && settingDate.before(date)){
    //				log.error("licence invalidation");
    //				throw new UsernameNotFoundException("licence invalidation");
    //			}
    //		} catch (Exception e) {
    //			log.error("licence invalidation");
    //			throw new UsernameNotFoundException("licence invalidation");
    //		}

    if (isTenant) {
      isCompanyValidDate(user);
    }
    Company company = companyManager.getCompany(user.getCompanyId());
    Department subCompany = null;
    if (user.getSubCompanyId() != null) {
      subCompany = departmentManager.getDepartmentById(user.getSubCompanyId());
    }
    List<GrantedAuthority> authsList = getAuthorityByUser(user);

    log.debug("*** loadUserByUsername 结束");
    return createUserdetail(user, company, authsList, subCompany, loginName);
  }
Beispiel #7
0
 public void rtxReminder(WorkflowTask task) {
   String msg =
       new StringBuilder("(")
           .append(new SimpleDateFormat("yyyy-MM-dd").format(new Date(System.currentTimeMillis())))
           .append(")任务:")
           .append(task.getTitle())
           .append("已经生成")
           .append(((System.currentTimeMillis() - task.getCreatedTime().getTime()) / MILLI_SECOND))
           .append("天了。请尽快办理!")
           .toString();
   String url =
       SystemUrls.getSystemUrl(StringUtils.substring(task.getUrl(), 0, task.getUrl().indexOf('/')))
           + StringUtils.substring(task.getUrl(), task.getUrl().indexOf('/'));
   if (url.contains("?")) {
     url = url + task.getId();
   } else {
     url = url + "?taskId=" + task.getId();
   }
   User user = userManager.getUserByLoginName(task.getTransactor());
   rtx.RtxMsgSender.sendNotify(task.getTransactor(), "任务办理提醒", "1", msg, url, user.getCompanyId());
 }
 /**
  * 工作组用户列表
  *
  * @return
  * @throws Exception
  */
 @Action("work-group-getUserByWorkGroup")
 public String getUserByWorkGroup() throws Exception {
   containBranches = departmentManager.containBranches();
   if (userPage.getPageSize() <= 1) {
     User user = userManager.getUserById(ContextUtils.getUserId());
     if (!roleManager.hasSystemAdminRole(user) && roleManager.hasBranchAdminRole(user)) {
       List<BranchAuthority> branchesList =
           branchAuthorityManager.getBranchByUser(ContextUtils.getUserId());
       for (BranchAuthority branches : branchesList) {
         if (StringUtils.isNotEmpty(manageBranchesIds)) {
           manageBranchesIds += ",";
         }
         manageBranchesIds += branches.getBranchesId();
       }
     }
     return "work-group-users";
   } else {
     if (workGroupId != null) {
       userPage = userInfoManager.queryUsersByWorkGroup(userPage, workGroupId);
     }
     renderHtml(PageUtils.pageToJson(userPage));
     return null;
   }
 }
Beispiel #9
0
 /** 保存任务 */
 @Override
 public String save() throws Exception {
   log.debug("*** save 办理任务方法开始");
   log.debug(
       new StringBuilder("*** Received parameter:[")
           .append("task:")
           .append(task)
           .append("]")
           .toString());
   ApiFactory.getBussinessLogService().log("工作流管理", "保存任务", ContextUtils.getSystemId("wf"));
   // 如果为分发环节,指定被分发人
   if (TaskProcessingMode.TYPE_DISTRIBUTE.toString().equals(task.getProcessingMode().toString())) {
     return "distribute";
   }
   // 如果为交办环节,指定被交办人
   if (task.getActive() == 0
       && TaskProcessingMode.TYPE_ASSIGN.toString().equals(task.getProcessingMode().toString())) {
     moreTransactor = true;
     workflowInstanceManager.saveData(task, null);
     return "assignTree";
   }
   // 如果已经办理但没有指定办理人
   if (task.getActive() == 1 && task.getProcessingMode() != TaskProcessingMode.TYPE_ASSIGN) {
     return assignTransactor();
   }
   String to = "";
   try {
     CompleteTaskTipType result =
         taskService.completeWorkflowTaskAndSaveData(
             task,
             transact,
             TaskSetting.getTaskSettingInstance()
                 .setTransitionName(transitionName)
                 .setAssignmentTransactors(newTransactor));
     switch (result) {
       case OK:
         this.addSuccessMessage(result.getContent());
         to = input();
         break;
       case MESSAGE:
         this.addErrorMessage(result.getContent());
         to = INPUT;
         break;
       case RETURN_URL:
         to = assignTransactor();
         break;
       case TACHE_CHOICE_URL:
         addActionMessage("请选择环节");
         canChoiceTaches = result.getCanChoiceTaches();
         to = choiceTache();
         break;
       case SINGLE_TRANSACTOR_CHOICE:
         User temp;
         for (String tran : result.getCanChoiceTransactor()) {
           temp = userManager.getUserByLoginName(tran);
           if (temp != null) canChoiceTransactor.put(tran, temp.getName());
         }
         moreTransactor = CompleteTaskTipType.SINGLE_TRANSACTOR_CHOICE.getContent().equals("true");
         to = "singleTransactorChoice";
     }
   } catch (TransactorAssignmentException e) {
     nullAssignmentException = "下一环节没有办理人,请指定!";
     return "assignmentTree";
   } catch (DecisionException de) {
     transitionNames = de.getTransitionNames();
     messageTip = de.getMessage();
     messageTip = getText(messageTip);
     return input();
   }
   return to;
 }
Beispiel #10
0
 public static List<Workgroup> getWorkGroupsByUser(String loginName) {
   UserManager userManager = (UserManager) ContextUtils.getBean("userManager");
   return userManager.getWorkgroupsByUser(loginName);
 }
Beispiel #11
0
 public static Workgroup getWorkGroupByName(String workGroupName) {
   UserManager userManager = (UserManager) ContextUtils.getBean("userManager");
   return userManager.getWorkgroupByName(workGroupName);
 }
Beispiel #12
0
 public static Set<String> getUsersNotInWorkGroup(Set<Workgroup> workgroupSet) {
   UserManager userManager = (UserManager) ContextUtils.getBean("userManager");
   Set<Workgroup> allWorkGroup = new HashSet<Workgroup>(userManager.getWorkgroups());
   allWorkGroup.removeAll(workgroupSet);
   return getUsersByWorkGroup(allWorkGroup);
 }