Example #1
0
 public static Set<String> getUsersByWorkGroup(Set<Workgroup> workgroupSet) {
   Set<String> userNames = new HashSet<String>();
   for (Workgroup workGroup : workgroupSet) {
     userNames.addAll(
         getUserLoginName(ApiFactory.getAcsService().getUsersByWorkgroupId(workGroup.getId())));
   }
   return userNames;
 }
 /** 新建工作组 */
 @Action("work-group-inputWorkGroup")
 public String inputWorkGroup() throws Exception {
   companyId = companyManager.getCompanyId();
   if (workGroup.getId() == null) {
     workGroup.setCode(createWorkGroupCode());
     workGroup.setSubCompanyId(branchesId);
   }
   return "work-group-input";
 }
 private String createWorkGroupCode() {
   int num = 0;
   List<Workgroup> Workgroups = workGroupManager.getDefaultCodeWorkGroups();
   if (Workgroups != null && Workgroups.size() > 0) {
     for (Workgroup w : Workgroups) {
       String codeNum = w.getCode().replace("workgroup-", "");
       if (codeNum.matches("^-?\\d+$") && Integer.valueOf(codeNum) > num) {
         num = Integer.valueOf(codeNum);
       }
     }
   } else {
     return "workgroup-1";
   }
   return "workgroup-" + (num + 1);
 }
 private boolean validateOnly(List<Workgroup> workgroupList, Long id) {
   boolean repeat = false;
   if (id == null) {
     if (workgroupList != null && workgroupList.size() > 0) {
       repeat = true;
     }
   } else {
     for (Workgroup w : workgroupList) {
       if (!id.equals(w.getId())) {
         repeat = true;
         break;
       }
     }
   }
   return repeat;
 }
 @Override
 @Action("work-group-delete")
 public String delete() throws Exception {
   String logSign = ""; // 该字段只是为了标识日志信息:工作组名称
   String[] str = ides.split(",");
   for (String sid : str) {
     workGroup = workGroupManager.getWorkGroup(Long.valueOf(sid));
     workGroupManager.cleanWorkGroup(workGroup.getId());
     if (StringUtils.isNotEmpty(logSign)) {
       logSign += ",";
     }
     logSign += workGroup.getName();
     workGroupManager.deleteWorkGroup(Long.valueOf(sid));
   }
   ApiFactory.getBussinessLogService()
       .log("工作组管理", "删除工作组:" + logSign, ContextUtils.getSystemId("acs"));
   this.renderText("ok");
   return null;
 }
  /** 保存新建工作组信息 */
  @Action("work-group-saveWorkGroup")
  public String saveWorkGroup() throws Exception {
    boolean logSign = true; // 该字段只是为了标识日志信息:true表示新建工作组、false表示修改工作组
    if (id == null) {
      Company company = companyManager.getCompany(companyId);
      workGroup.setCompany(company);
      workGroupManager.saveWorkGroup(workGroup);
    } else {
      workGroupManager.saveWorkGroup(workGroup);
      logSign = false;
    }

    if (logSign) {
      ApiFactory.getBussinessLogService()
          .log("工作组管理", "新建工作组:" + workGroup.getName(), ContextUtils.getSystemId("acs"));
    } else {
      ApiFactory.getBussinessLogService()
          .log("工作组管理", "修改工作组:" + workGroup.getName(), ContextUtils.getSystemId("acs"));
    }
    addSuccessMessage("保存成功");
    return null;
  }