예제 #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();
  }
예제 #2
0
 /**
  * 判断用户是不是在部门里,如果在返回ture;否则,返回false。
  *
  * @param companyId
  * @param loginName
  * @param departmentName
  * @return 用户在部门里,返回ture;否则,返回false。
  */
 public static boolean userInDepartment(Long companyId, String loginName, String departmentName) {
   if (ContextUtils.getCompanyId() == null) {
     ThreadParameters parameters = new ThreadParameters(companyId);
     ParameterUtils.setParameters(parameters);
   }
   List<Department> departments = ApiFactory.getAcsService().getDepartments(loginName);
   for (Department department : departments) {
     if (department.getName().equals(departmentName)) {
       return true;
     }
   }
   return false;
 }
예제 #3
0
 /**
  * 判断用户是不是在工作组里,如果在返回ture;否则,返回false。
  *
  * @param companyId
  * @param loginName
  * @param departmentName
  * @return 用户在工作组里,返回ture;否则,返回false。
  */
 public static boolean userInWorkGroup(Long companyId, String loginName, String workGroupName) {
   if (ContextUtils.getCompanyId() == null) {
     ThreadParameters parameters = new ThreadParameters(companyId);
     ParameterUtils.setParameters(parameters);
   }
   List<com.norteksoft.product.api.entity.Workgroup> workGroups =
       ApiFactory.getAcsService().getWorkgroupsByUser(loginName);
   for (com.norteksoft.product.api.entity.Workgroup workGroup : workGroups) {
     if (workGroup.getName().equals(workGroupName)) {
       return true;
     }
   }
   return false;
 }
예제 #4
0
 /**
  * 没有部门的用户的树节点
  *
  * @param companyId
  * @return
  */
 public String getNoDepartmentUserNodes(Long companyId) {
   StringBuilder nodes = new StringBuilder();
   ThreadParameters parameters = new ThreadParameters(companyId);
   ParameterUtils.setParameters(parameters);
   List<User> users = ApiFactory.getAcsService().getUsersWithoutDepartment();
   for (User user : users) {
     if (user.isDeleted()) continue;
     nodes
         .append(
             JsTreeUtils.generateJsTreeNodeDefault(
                 "USER," + user.getId() + "," + user.getLoginName(), "", user.getName(), ""))
         .append(",");
   }
   JsTreeUtils.removeLastComma(nodes);
   return nodes.toString();
 }
예제 #5
0
 /**
  * 判断用户是不是拥有某权限,如果有返回ture;否则,返回false。
  *
  * @param companyId
  * @param loginName
  * @param departmentName
  * @return 用户拥有某权限,返回ture;否则,返回false。
  */
 public static boolean userHaveRole(Long companyId, String loginName, String roleName) {
   // 获得子系统的id集合
   BusinessSystemManager businessSystemManager =
       (BusinessSystemManager) ContextUtils.getBean("businessSystemManager");
   List<Long> subSystemIds =
       businessSystemManager.getSystemIdsByParentCode(ContextUtils.getSystemCode());
   if (ContextUtils.getCompanyId() == null) {
     ThreadParameters parameters = new ThreadParameters(companyId);
     ParameterUtils.setParameters(parameters);
   }
   Set<Role> roles = ApiFactory.getAcsService().getRolesByUser(loginName);
   for (Role role : roles) {
     if (role.getName().equals(roleName)) {
       boolean result = validateRole(role, subSystemIds);
       if (result) {
         return result;
       } else {
         continue;
       }
     }
   }
   return false;
 }
 @Before
 public void init() {
   ThreadParameters parameters = new ThreadParameters(null, null);
   parameters.setCompanyId(1L);
   ParameterUtils.setParameters(parameters);
 }