Example #1
0
 /**
  * 修改密码
  *
  * @return
  */
 public String editPassword() {
   User dbResult = userManager.getById(getCurrUser().getUserID());
   User user = this.userManager.getById(getCurrUser().getUserID());
   String pwd = getRequest().getParameter("password");
   String pwdold = getRequest().getParameter("password_old");
   String msg = "修改密码成功";
   int type = 1;
   if (pwdold.equals(dbResult.getPassword())) {
     dbResult.setPassword(pwd);
     try {
       userManager.saveOrUpdate(dbResult);
       // 提示信息
       Flash.current().success(RESET_PASSWORD_SUCCESS);
     } catch (Exception e) {
       e.printStackTrace();
       msg = "修改密码失败!";
       type = 2;
       // 提示信息
       // Flash.current().success(RESET_PASSWORD_FAILURE);
     }
   } else {
     msg = "原始密码错误!";
     type = 3;
   }
   getRequest().setAttribute("type", type);
   getRequest().setAttribute("msg", msg);
   return "update_password";
 }
Example #2
0
 /** 保存新增草稿 */
 public String saveadd() {
   String title = getRequest().getParameter("title");
   String content = getRequest().getParameter("content");
   String receids = getRequest().getParameter("receids");
   String[] rids = receids.split(",");
   for (String rid : rids) {
     User user = userManager.getById(rid);
     Message mess = new Message();
     mess.setTitle(title);
     mess.setContent(content);
     mess.setReceiverId(user.getId());
     mess.setReceiver(user.getUsername());
     mess.setStatus("0"); // 未发送
     mess.setTime(new Date());
     mess.setState("0"); // 消息状态    0为未查看
     mess.setTs(new Date());
     mess.setSponsor(this.getCurrUser().getUserName());
     mess.setSponsorId(this.getCurrUser().getUserID());
     this.messageManager.save(mess);
     if (file != null) {
       uploadFile(mess.getId()); // 上传附件
     }
   }
   return "sendAction";
 }
Example #3
0
  /**
   * 保存更新对象
   *
   * @return
   */
  public String update() {
    this.organizationUserRelationManager.removeOURByUserId(user.getId());
    if (user.getDeptIDs() != null && !user.getDeptIDs().equals("")) {
      String[] organizationIds = user.getDeptIDs().split(",");
      for (String organizationId : organizationIds) {
        OrganizationUserRelation our = new OrganizationUserRelation();
        our.setOrganizationId(organizationId);
        our.setUserId(user.getId());
        this.organizationUserRelationManager.save(our);
      }
    }
    // user.setOuRelations(ours);
    /*if (user.getIsLeave().equals("0")) // 已离职 账户禁用 1 启用 0
    {
    	user.setAbledFlag("1");
    } else if (user.getIsLeave().equals("1")) {
    	user.setAbledFlag("0");
    } else {
    	if (this.abledFlag != null && !this.abledFlag.equals("")) {
    		// user.setAbledFlag("0");
    		user.setAbledFlag(this.abledFlag);
    	}
    }*/
    // 加密工资
    try {

    } catch (Exception e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
    }
    this.userManager.update(user);

    Flash.current().success(UPDATE_SUCCESS);
    return LIST_ACTION;
  }
Example #4
0
 /**
  * 更改用户类型
  *
  * @return
  */
 public String updatetype() {
   String ids = getRequest().getParameter("ids");
   String[] userIds = ids.split(",");
   String source = this.getRequest().getParameter("source");
   if (!isNullOrEmptyString(source)) {
     for (String uid : userIds) {
       User user = userManager.getById(uid);
       user.setSource(source);
       userManager.update(user);
     }
   }
   return LIST_ACTION;
 }
Example #5
0
  /**
   * 发起测评 -- 跨单位
   *
   * @return
   */
  public String outUserList() {
    Page page = this.userManager.findOutPage(query, this.getCurrUser().getDeptIDs());
    String userId = query.getId();
    List<User> userList = page.getResult();

    for (User user : userList) {
      String uId = user.getId();
      if (!isNullOrEmptyString(userId)) {
        if (userId.indexOf(uId) != -1) {
          user.setChecked("1");
        }
      }
    }

    super.saveCurrentPage(page, query);
    return "outUserList";
  }
Example #6
0
  public String sponsorList() {
    Page page = this.userManager.findHead(query);
    String userId = query.getId();
    List<User> usersList = page.getResult();

    for (User user : usersList) {
      String uId = user.getId();
      if (!isNullOrEmptyString(userId)) {
        if (userId.indexOf(uId) != -1) {
          user.setChecked("1");
        }
      }
    }

    this.saveCurrentPage(page, query);
    return "sponsorList";
  }
Example #7
0
  /**
   * 删除对象
   *
   * @return
   */
  public String delete() {

    String deleteMessage = "";
    for (int i = 0; i < items.length; i++) {
      Hashtable params = HttpUtils.parseQueryString(items[i]);
      String id = (String) params.get("id");
      User user = userManager.getById(id);

      try {
      } catch (Exception e) {
      }

      // 超级管理员禁止删除
      if (user.getLoginname() != null && user.getLoginname().equals("admin")) {
        deleteMessage = "超级管理员禁止删除";
      } else {
        // 删除时,置换删除标记
        user.setDf("1");
        // 删除人员时 需要把人员与角色的关系 以及管理员与分区的关系删除
        user.setRoles(new HashSet<Role>(0));
        user.setOuRelations(null);
        user.setPartitions(new HashSet<Partition>(0));

        userManager.delete(user);
      }
    }

    if (deleteMessage != null && !deleteMessage.equals("")) {
      Flash.current().success(deleteMessage);
    } else {
      Flash.current().success(DELETE_SUCCESS);
    }

    return LIST_ACTION;
  }
Example #8
0
  /**
   * 重置密码
   *
   * @return
   */
  public String resetPassword() {

    try {
      User user = this.userManager.getById(id);
      // 默认重置为000000
      user.setPassword("111111");
      this.userManager.save(user);

      // 提示信息
      Flash.current().success(RESET_PASSWORD_SUCCESS);
    } catch (Exception e) {
      e.printStackTrace();

      // 提示信息
      Flash.current().success(RESET_PASSWORD_FAILURE);
    }
    return LIST_ACTION;
  }
Example #9
0
  /**
   * 查看对象
   *
   * @return
   */
  public String show() {
    // 处理部门名称

    user.setDeptsString("");
    if (user.getOuRelations() != null) {
      StringBuffer sb = new StringBuffer();
      for (OrganizationUserRelation our : user.getOuRelations()) {
        if (our.getOrganization() != null) {
          sb.append(our.getOrganization().getName() + ",");
        }
      }
      user.setDeptsString(
          sb.length() > 0 ? sb.substring(0, sb.length() - 1).toString() : sb.toString());
    }

    /*// 性别
    if (user.getSex() != null && !user.getSex().equals("")) {
    	this.sexMap = dicUtil.getDicList("DICT_SEX");
    	user.setSexString(this.sexMap.get(user.getSex()));
    }*/

    try {
      /*
       * WebApplicationContext wac =
       * WebApplicationContextUtils.getRequiredWebApplicationContext
       * (getRequest().getSession().getServletContext()); PictureService
       * pictureService = (PictureService)wac.getBean("pictureService");
       * //调用webservice方法 AttachmentImpl [] attachments =
       * pictureService.findAttachment(user.getId(), FILE_NAME,FILE_MODEL);
       * if(attachments!=null && attachments.length>0) {
       * getRequest().setAttribute("attachment",attachments[0]); }
       */

      ClientAttachmentService clientAttach = new ClientAttachmentService();
      List<Attachment> attachmentList =
          clientAttach.findAttachmentByXml(user.getId(), FILE_NAME, FILE_MODEL);
      if (attachmentList.size() > 0) {
        getRequest().setAttribute("attachment", attachmentList.get(0));
      }
    } catch (Exception e) {
      // TODO: handle exception
    }
    return SHOW_JSP;
  }
Example #10
0
  /**
   * 根据岗位加载对应的用户列表,跳转到设置用户界面
   *
   * @return
   */
  public String setUserForStation() {
    // 准备数据
    Station station = this.stationManager.getById(this.stationId);
    if (station != null) {
      StringBuffer sbIds = new StringBuffer();
      StringBuffer sbNames = new StringBuffer();
      StringBuffer html = new StringBuffer();
      // selectedIds
      // selectedNames
      // selectedUserHTML
      Set<User> users = station.getUsers(); // ,过滤掉是删除状态的用户
      Set<User> users_ = new HashSet<User>(0);
      for (User user : users) {
        if (user.getDf().equals("0")) {
          users_.add(user);
        }
      }

      for (User user : users_) {
        sbIds.append(user.getId() + ",");
        sbNames.append(user.getUsername() + ",");
        html.append("<div class='iframe_name_box' id='" + user.getId() + "'>");
        html.append("<p class='iframe_name_text'>" + user.getUsername() + "</p>");
        html.append("<p class='iframe_name_close'>");
        html.append(
            "<a onclick=\"delItem('" + user.getId() + "', '" + user.getUsername() + "')\">");
        html.append(
            "<img src='"
                + ServletActionContext.getRequest().getContextPath()
                + "/images/component/open_textboxclose.gif' width='11' height='11' />");
        html.append("</a>");
        html.append("</p>");
        html.append("</div>");
      }
      getRequest().setAttribute("selectedUserHTML", html.toString());

      if (sbIds.toString() != null && !sbIds.toString().equals("")) {
        String _sbIds = sbIds.substring(0, sbIds.toString().length() - 1);
        getRequest().setAttribute("selectedIds", _sbIds);
      }
      if (sbNames.toString() != null && !sbNames.toString().equals("")) {
        String _sbNames = sbNames.toString().substring(0, sbNames.toString().length() - 1);
        getRequest().setAttribute("selectedNames", _sbNames);
      }
    }

    return "stationUserMain";
  }
Example #11
0
  /**
   * 进入更新页面
   *
   * @return
   */
  public String edit() {
    getRequest().setAttribute(DEPTS, organizationManager.findAllByDf());
    // 性别
    this.sexMap = dicUtil.getDicList("DICT_SEX");
    // 组织机构IDS
    StringBuffer sbId = new StringBuffer();
    StringBuffer sbText = new StringBuffer();
    for (OrganizationUserRelation our : user.getOuRelations()) {

      if (our.getOrganization() != null) {
        sbId.append(our.getOrganization().getId() + ",");
        sbText.append(our.getOrganization().getName() + ",");
      }
    }
    try {
      // 创建一个webservice
      /*
       * WebApplicationContext wac =
       * WebApplicationContextUtils.getRequiredWebApplicationContext
       * (getRequest().getSession().getServletContext()); PictureService
       * pictureService = (PictureService)wac.getBean("pictureService");
       * AttachmentImpl [] attachments =
       * pictureService.findAttachment(user.getId(),
       * FILE_NAME,FILE_MODEL);
       */
      ClientAttachmentService clientAttach = new ClientAttachmentService();
      List<Attachment> attachments =
          clientAttach.findAttachmentByXml(user.getId(), FILE_NAME, FILE_MODEL);
      if (attachments != null && attachments.size() > 0) {
        getRequest().setAttribute("attachment", attachments.get(0));
      }
    } catch (Exception e) {
      getRequest().setAttribute("attachment", null);
    }

    String ids = sbId.toString();
    String texts = sbText.toString();
    if (ids != null && !ids.equals("")) {
      user.setDeptIDs(ids.substring(0, ids.length() - 1));
      user.setDeptsString(texts.substring(0, texts.length() - 1));
    }
    return EDIT_JSP;
  }
Example #12
0
  /**
   * 批量 启用/停用 0/1
   *
   * @return
   */
  public String batchAble() {
    String message = "";
    for (int i = 0; i < items.length; i++) {
      Hashtable params = HttpUtils.parseQueryString(items[i]);
      String id = (String) params.get("id");
      User user = userManager.getById(id);

      // 超级管理员不允许禁用
      if (user.getLoginname() != null && user.getLoginname().equals("admin")) {
        message = "超级管理员禁止执行当前操作";
      } else {
        if (ableFlag != null && ableFlag.equals("enabled")) {
          if (user.getIsLeave().equals("0")) // 判断是否离职,如果已离职,则不允许启用该用户
          {
            message = "该员工已离职!不允许做操作!";
          } else {
            user.setAbledFlag("0");
          }
        }
        if (ableFlag != null && ableFlag.equals("disabled")) {
          user.setAbledFlag("1");
        }
        this.userManager.save(user);
      }
    }

    if (message != null && !message.equals("")) {
      Flash.current().success(message);
    } else {
      Flash.current().success(ADMIT_SUCCESS);
    }

    return LIST_ACTION;
  }
Example #13
0
  /**
   * 修改个人设置页面
   *
   * @return
   */
  public String editPersonPage() {
    user = userManager.getById(getCurrUser().getUserID());
    // getRequest().setAttribute("depts", deptManager.findAll());
    // getRequest().setAttribute(DEPTS, organizationManager.findAllByDf());

    // 性别
    this.sexMap = dicUtil.getDicList("DICT_SEX");
    // 组织机构IDS
    StringBuffer sbId = new StringBuffer();
    StringBuffer sbText = new StringBuffer();
    for (OrganizationUserRelation our : user.getOuRelations()) {
      sbId.append(our.getOrganization().getId() + ",");
      sbText.append(our.getOrganization().getName() + ",");
    }
    String ids = sbId.toString();
    String texts = sbText.toString();
    if (ids != null && !ids.equals("")) {
      user.setDeptIDs(ids.substring(0, ids.length() - 1));
      user.setDeptsString(texts.substring(0, texts.length() - 1));
    }
    return EDIT_PERSON_INFO;
  }
Example #14
0
  /**
   * 加载用户列表,用于选择用户组件
   *
   * @return
   */
  @SuppressWarnings("unchecked")
  public String loadUserList() {
    query.setDf("0");
    // 如果是取某分区下的用户,根据分区下的组织机构取得所有用户
    if (partitionId != null && !"".equals(partitionId)) {
      Partition partition = partitionManager.getById(partitionId);
      if (partition != null) {
        query.setOrganizIds(organizationManager.findAllChildByPartition(partition));
      }
    }

    Page page = this.organizationUserRelationManager.findByUserPage(query);
    page = userManager.findPage(query);

    List<User> users = page.getResult();
    // 处理部门列表
    for (User user : users) {
      user.setDeptsString("");
      if (user.getOuRelations() != null) {
        StringBuffer sb = new StringBuffer();
        for (OrganizationUserRelation our : user.getOuRelations()) {
          if (our.getOrganization() != null) {
            sb.append(our.getOrganization().getName() + ",");
          }
        }
        user.setDeptsString(sb.toString());
      }
    }
    // 性别
    for (User user : users) {
      /*if (user.getSex() != null && !user.getSex().equals("")) {
      	this.sexMap = this.dicUtil.getDicList("DICT_SEX");
      	user.setSexString(this.sexMap.get(user.getSex()));
      }*/
    }
    this.saveCurrentPage(page, query);
    return "loadUserList";
  }
Example #15
0
  /**
   * 角色授予
   *
   * @return
   */
  public String grantRole() {
    Set<Role> roles = new HashSet<Role>(0);
    if (items != null) {
      for (String roleID : items) {
        Role role = roleManager.getById(roleID);
        roles.add(role);
      }
    }
    user.setRoles(roles);
    userManager.saveOrUpdate(user);

    // Flash.current().success(UPDATE_SUCCESS);
    return "closeDialog";
  }
Example #16
0
  /**
   * 执行搜索
   *
   * @return
   */
  @SuppressWarnings("unchecked")
  public String list() {

    // Flash.current().clear();

    /*// 删除标记的不显示
    query.setDf("0");
    // 启用状态
    query.setAbledFlag(this.abledFlag);
    // 如果是取某分区下的用户,根据分区下的组织机构取得所有用户
    if (partitionId != null && !"".equals(partitionId)) {
    	Partition partition = partitionManager.getById(partitionId);
    	if (partition != null) {
    		query.setOrganizIds(organizationManager.findAllChildByPartition(partition));
    	}
    }*/

    Page page = this.organizationUserRelationManager.findByUserPage(query);

    List<User> users = page.getResult();
    // 处理部门列表
    for (User user : users) {
      user.setDeptsString("");
      if (user.getOuRelations() != null) {
        StringBuffer sb = new StringBuffer();
        for (OrganizationUserRelation our : user.getOuRelations()) {
          if (our.getOrganization() != null) {
            sb.append(our.getOrganization().getName() + ",");
          }
        }
        user.setDeptsString(sb.toString());
      }
    }

    this.saveCurrentPage(page, query);
    return LIST_JSP;
  }
Example #17
0
  // 设置管理员
  public String grantAdministrator() {
    if (this.selectedUserIds != null && !this.selectedUserIds.equals("")) {
      Set<User> users = new HashSet<User>(0);
      String[] ids = this.selectedUserIds.split(",");
      for (String id : ids) {
        User user = this.userManager.getById(id);

        users.add(user);

        // 给用户绑定分区管理员角色
        Role role = this.roleManager.findByDf("code", "Partition_admin");
        Set<Role> roles = user.getRoles();
        roles.add(role);
        user.setRoles(roles);
        this.userManager.update(user);
      }
      //			this.partition.setUsers(users);
    } else {
      //			this.partition.setUsers(null);
    }

    this.partitionManager.update(partition);
    return CLOSE_DIALOG;
  }
Example #18
0
  /**
   * 进入权限授予页面
   *
   * @return
   */
  public String grantPage() {
    List<Role> roles = roleManager.findAllByDf();
    if (partitionId != null && !"".equals(partitionId)) {
      String roleIdsByPartition = "";
      List<Role> rolesByPartition = roleManager.findAllByDf("partitionId", partitionId);
      for (Role r : rolesByPartition) {
        roleIdsByPartition += r.getId() + "|";
        getRequest().setAttribute("roleIdsByPartition", roleIdsByPartition);
      }
    }

    String roleEd = "";

    for (Role role : user.getRoles()) {
      if (role != null) {
        roleEd = roleEd + "," + role.getId();
      }
    }

    getRequest().setAttribute("roles", roles);
    getRequest().setAttribute("roleEd", roleEd);
    return GRANT_ROLE_PAGE;
  }
  @Override
  public String[][] getAllData(
      String code, String username, String password, int startIndex, int endIndex) {
    // 操作流程
    // 首先根据code,查找到对应的数据记录,判断username和password是否匹配,如果匹配则返回关联的用户列表
    com.opendata.sys.model.System system = this.systemManager.findByDf("code", code);
    if (system != null) {
      // 判断username和password是否匹配
      if (system.getUsername().equals(username) && system.getPassword().equals(password)) {
        Set<User> users = new HashSet<User>();
        // 支持分页
        if (startIndex == 0 && endIndex == 0) {
          // 用户列表
          users = system.getUsers();
        } else {
          users = this.systemManager.findAllData(system.getUsers(), startIndex, endIndex);
        }

        if (users != null && users.size() > 0) {
          String[][] userList = new String[users.size()][4];
          int row = 0;
          for (User user : users) {
            userList[row][0] = user.getId(); // 唯一标示
            userList[row][1] = user.getUsername(); // 用户名
            userList[row][2] = null; // 组织机构ids
            userList[row][3] = null; // 组织机构名称
            // 组织机构
            Set<OrganizationUserRelation> ours = user.getOuRelations();
            StringBuffer organizationIds = new StringBuffer();
            StringBuffer organizationNames = new StringBuffer();
            for (OrganizationUserRelation our : ours) {
              if (our.getOrganization() != null) {
                organizationIds.append(our.getOrganization().getId() + ",");
                organizationNames.append(our.getOrganization().getName() + ",");
              }
            }
            if (organizationIds.toString().length() > 0) {
              String _organizationIds =
                  organizationIds.toString().substring(0, organizationIds.toString().length() - 1);
              userList[row][2] = _organizationIds; // 组织机构ids
            }
            if (organizationNames.toString().length() > 0) {
              String _organizationNames =
                  organizationNames
                      .toString()
                      .substring(0, organizationNames.toString().length() - 1);
              userList[row][3] = _organizationNames; // 组织机构名称
            }
          }

          return userList;
        }
      } else {
        // 用户名或密码错误
      }
    } else {
      // 没有匹配的数据
    }

    return null;
  }
Example #20
0
  /**
   * 保存新增对象
   *
   * @return
   */
  public String save() {

    if (partitionId != null
        && !"".equals(partitionId)
        && (user.getDeptIDs() == null || "".equals(user.getDeptIDs()))) {
      Flash.current().error("分区下用户必须选择组织机构!");
      return CREATE_JSP;
    }

    // 校验登录名是否重复
    User _user = this.userManager.findByName(user.getLoginname());
    if (_user != null) {

      // 性别
      this.sexMap = dicUtil.getDicList("DICT_SEX");
      // 部门列表
      // getRequest().setAttribute(DEPTS, deptManager.findAll());
      getRequest().setAttribute(DEPTS, organizationManager.findAllByDf());

      // 登录名重复
      Flash.current().error("登录名已经存在,请重新填写!");
      return CREATE_JSP;
    }

    user.setTs(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
    // 设置删除标记
    user.setDf("0");
    // 默认启用
    if (user.getIsLeave().equals("0")) // 已离职 账户禁用 0 启用 1
    {
      user.setAbledFlag("1");
    } else {
      user.setAbledFlag("0");
    }
    // user.setPhoto(getRequest().getParameter("articleAttachPic"));
    userManager.save(user);
    // 创建一个webservice
    /*
     * WebApplicationContext wac =
     * WebApplicationContextUtils.getRequiredWebApplicationContext
     * (getRequest().getSession().getServletContext()); PictureService
     * pictureService = (PictureService)wac.getBean("pictureService");
     * pictureService
     * .saveAttach(user.getId(),getRequest().getParameter("attach_client_id"
     * ), getRequest().getParameter("attach_form_key"), FILE_NAME,FILE_MODEL
     * );
     */
    ClientAttachmentService clientAttach = new ClientAttachmentService();
    clientAttach.saveAttach(
        user.getId(),
        getRequest().getParameter("attach_client_id"),
        getRequest().getParameter("attach_form_key"),
        FILE_NAME,
        FILE_MODEL);
    // 用户和组织机构的这种关系需要清除了
    if (user.getDeptIDs() != null && !user.getDeptIDs().equals("")) {
      String[] organizationIds = user.getDeptIDs().split(",");
      for (String organizationId : organizationIds) {
        OrganizationUserRelation our = new OrganizationUserRelation();
        our.setUserId(user.getId());
        our.setOrganizationId(organizationId);
        this.organizationUserRelationManager.save(our);
      }
    }
    Flash.current().success(CREATED_SUCCESS); // 存放在Flash中的数据,在下一次http请求中仍然可以读取数据,error()用于显示错误消息
    return LIST_ACTION;
  }