예제 #1
0
  @Transactional(readOnly = false)
  public void run() throws Exception {
    List<Company> companys = acsUtils.getAllCompanys();
    for (Company company : companys) {
      ThreadParameters parameters = new ThreadParameters(company.getId());
      ParameterUtils.setParameters(parameters);
      String systemAdmin = ApiFactory.getAcsService().getSystemAdminLoginName();
      parameters = new ThreadParameters(company.getId());
      parameters.setUserName("系统");
      parameters.setLoginName(systemAdmin);
      ParameterUtils.setParameters(parameters);

      // 委托
      delegateMain();

      // 催办
      List<WorkflowTask> result = new ArrayList<WorkflowTask>();
      result.addAll(workflowInstanceManager.getNeedReminderTasksByInstance());
      result.addAll(taskService.getNeedReminderTasks());
      reminder(result);
    }
    deleteExportTempFile();

    // 清空同步处理时的实例map,见TaskService中的completeInteractiveWorkflowTask方法
    TaskService.instanceIds.clear();
  }
  /*
   * 创建spring security使用的用户
   * userinfo:loginName~~companyCode
   */
  private com.norteksoft.acs.entity.security.User createUserdetail(
      User user,
      Company company,
      List<GrantedAuthority> authsList,
      Department subCompany,
      String userinfo) {
    com.norteksoft.acs.entity.security.User userdetail =
        new com.norteksoft.acs.entity.security.User(
            user.getId(),
            userinfo,
            user.getPassword(),
            user.getEmail(),
            user.getEnabled(),
            !user.getAccountExpired(),
            true,
            !user.getAccountLocked(),
            authsList.toArray(new GrantedAuthority[authsList.size()]),
            company.getId(),
            company.getCode(),
            company.getName(),
            user.getSecretGrade());
    userdetail.setLoginName(user.getLoginName());
    userdetail.setHonorificTitle(user.getHonorificName());
    userdetail.setTrueName(user.getName());
    userdetail.setRoleCodes(user.getRoleCodes());
    String theme = indexManager.getThemeByUser(user.getId(), company.getId());
    if (StringUtils.isEmpty(theme)) theme = getDefaultTheme();
    userdetail.setTheme(theme);

    String language =
        userCurrentLanguageManager.getUserLanguageByUserId(user.getId(), company.getId());
    if (StringUtils.isEmpty(language)) language = getDefaultLanguage();
    userdetail.setCurrentLanguage(language);

    userdetail.setSubCompanyId(user.getSubCompanyId());
    userdetail.setDepartmentId(user.getMainDepartmentId());
    if (subCompany != null) {
      userdetail.setSubCompanyCode(subCompany.getCode());
      userdetail.setSubCompanyName(subCompany.getName());
      userdetail.setSubCompanyShortTitle(subCompany.getShortTitle());
    }
    return userdetail;
  }