Example #1
0
  /**
   * 进入新增页面
   *
   * @return
   */
  public String create() {
    // getRequest().setAttribute(DEPTS, deptManager.findAll());
    getRequest().setAttribute(DEPTS, organizationManager.findAllByDf());
    // 性别
    this.sexMap = dicUtil.getDicList("DICT_SEX");
    //		Dictitem item = dictitemManager.findByCode("post"); // 获取所有的岗位及岗位级别
    List stations = dictvalueManager.findByItemCode("post"); // 获取所有的一级岗位

    getRequest().setAttribute("stations", stations);
    getRequest().setAttribute("clientId", "userImage"); // 调用外部上传头像程序所必须的目录名
    return CREATE_JSP;
  }
Example #2
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 #3
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 #4
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;
  }