Example #1
0
  public String editAccountPassword() {
    boolean isSuccess = true;
    String result = "0";

    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession httpSession = request.getSession();
    Session session = (Session) httpSession.getAttribute("session");
    if (session != null) {
      try {
        Account account = (Account) accountManagerService.queryAccountByAccountId(session.getId());
        if (account != null) oldpassword = account.getPassword();
      } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
        result = "-1";
      }
    }
    StringBuffer msg = new StringBuffer("查询账号");
    switch (Integer.parseInt(result)) {
      case -1:
        msg.append("失败,数据库异常!");
        isSuccess = false;
        break;
      default:
        msg.append("成功。");
        isSuccess = true;
        break;
    }
    commonBean = new CommonBean(result, msg.toString());
    if (isSuccess) {
      return SUCCESS;
    } else {
      return ERROR;
    }
  }
Example #2
0
  // result:2--不存在;0:成功;-1:异常
  public String updateAccountPassword() {
    int resultForLog = AlarmConstants.RESULT_SUC;
    String message = "";
    boolean isSuccess = true;
    String result = "0";
    int resultForDel = -1;
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession httpSession = request.getSession();
    Session session = (Session) httpSession.getAttribute("session");
    if (session != null) {
      id = session.getId();
      try {
        if (!password.equals(rePassword.trim())) {
          result = "3";
        } else {
          result =
              String.valueOf(
                  accountManagerService.updateAccountPassword(
                      id, oldPasswd.trim(), password.trim()));
        }
      } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
        message = "数据库异常";
        resultForLog = AlarmConstants.RESULT_FAIL;
      }
    }
    operationLogService.createOperationLog("updateAccountPassword", id, resultForLog, message);

    StringBuffer msg = new StringBuffer("修改帐号密码").append(id);
    switch (Integer.parseInt(result)) {
      case 2:
        msg.append("失败,帐号密码已经不存在。");
        isSuccess = false;
        resultForDel = 0;
        break;
      case -1:
        msg.append("失败,数据库异常!");
        isSuccess = false;
        resultForDel = 0;
        break;
      case 3:
        msg.append("失败,两次密码输入不一致!");
        isSuccess = false;
        resultForDel = 0;
        break;
      default:
        msg.append("成功。");
        resultForDel = 1;
        isSuccess = true;
        break;
    }
    ajaxObject = new AjaxObject(resultForDel, msg.toString());
    if (isSuccess) {
      return SUCCESS;
    } else {
      return ERROR;
    }
  }
Example #3
0
 /**
  * 当前用户是否是总公司用户
  *
  * @return
  */
 public static boolean isHeadquarters() {
   Session session = getLoginSession();
   if (null != session) {
     String userLevel = session.getLev();
     if (userLevel.equals(AlarmConstants.USER_HEADQUARTERS)) {
       return true;
     }
   }
   return false;
 }
Example #4
0
 public static List<CommonBean> getDepartmentsCanBeSeen(
     IOrganizationManagerService organManagerService) {
   List<CommonBean> branchList = new ArrayList<CommonBean>();
   List<CommonBean> departmentList = new ArrayList<CommonBean>();
   Session session = getLoginSession();
   if (null != session) {
     String userLevel = session.getLev();
     if (userLevel.equals(AlarmConstants.USER_HEADQUARTERS)) {
       // 如果用户是总公司, 获取所有分公司,有全部
       branchList = session.getOrgIdAndNames().getSubCompanys();
       for (CommonBean commonBean : branchList) {
         List<CommonBean> tempdepartmentList =
             organManagerService.getOrgIdAndOrgNmsFor2ByPOrgId(commonBean.getId());
         departmentList.addAll(tempdepartmentList);
       }
     } else if (userLevel.equals(AlarmConstants.USER_BRANCH)) {
       // 如果用户是分公司级别, 获取用户所在分公司和分公司下的所有管理处
       // 界面的分公司下拉列表(无全部)默认为用户的分公司,管理处有全部
       branchList = session.getOrgIdAndNames().getSubCompanys();
       departmentList = session.getOrgIdAndNames().getManagements();
     } else if (userLevel.equals(AlarmConstants.USER_DEPARTMENT)) {
       // 如果用户是管理处级别, 获取用户所在分公司和所在管理处,所有防区
       // 界面的分公司下拉列表默认为用户的分公司,管理处下拉列表默认为用户管理处,都无全部
       branchList = session.getOrgIdAndNames().getSubCompanys();
       departmentList = session.getOrgIdAndNames().getManagements();
     }
   }
   return departmentList;
 }
Example #5
0
  /**
   * result:0:成功;-1:异常
   *
   * @return SUCCESS
   */
  public String entryCreateAccount() {
    boolean isSuccess = true;
    String result = "0";
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession httpSession = request.getSession();
    Session session = (Session) httpSession.getAttribute("session");

    if (session != null) {
      try {
        account = new Account();
        account.setBirthday(null);
        seledRoles = new ArrayList<String>();
        orgLevAndIdNames = accountManagerService.getOrgLevAndIdNamesByAccountId(session.getId());
        allowedRoles = accountManagerService.getAllowedRolesByAccountId();
      } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
        result = "-1";
      }
    } else result = "-2";
    StringBuffer msg = new StringBuffer("查询机构和角色");
    switch (Integer.parseInt(result)) {
      case -2:
        msg.append("失败,无Session对象!");
        isSuccess = false;
        break;
      case -1:
        msg.append("失败,数据库异常!");
        isSuccess = false;
        break;
      default:
        msg.append("成功。");
        isSuccess = true;
        break;
    }
    commonBean = new CommonBean(result, msg.toString());
    if (isSuccess) {
      return SUCCESS;
    } else {
      return ERROR;
    }
  }
Example #6
0
  /**
   * result:0:成功;-1:异常
   *
   * @return SUCCESS
   */
  public String queryAccountsByAccountId() {
    int resultForLog = AlarmConstants.RESULT_SUC;
    String message = "";
    boolean isSuccess = true;
    String result = "0";

    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession httpSession = request.getSession();
    Session session = (Session) httpSession.getAttribute("session");
    if (session != null) {
      try {
        accounts = accountManagerService.queryAccountsByAccountId(session.getId());
      } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
        result = "-1";
        message = "数据库异常";
        resultForLog = AlarmConstants.RESULT_FAIL;
      }
    }
    // operationLogService.createOperationLog("queryAccountsByAccountId",
    // "",
    // resultForLog, message);
    StringBuffer msg = new StringBuffer("查询帐号");
    switch (Integer.parseInt(result)) {
      case -1:
        msg.append("失败,数据库异常!");
        isSuccess = false;
        break;
      default:
        msg.append("成功。");
        isSuccess = true;
        break;
    }
    commonBean = new CommonBean(result, msg.toString());
    if (isSuccess) {
      return SUCCESS;
    } else {
      return ERROR;
    }
  }
Example #7
0
  // result:1--已存在;0:成功;-1:异常
  public String createAccount() {
    int resultForLog = AlarmConstants.RESULT_SUC;
    String message = "";
    boolean isSuccess = true;
    String result = null;

    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession httpSession = request.getSession();
    Session session = (Session) httpSession.getAttribute("session");

    String homeAddress = account.getHomeAddress();
    String homeTel = account.getHomeTel();
    String id = account.getId();
    String mail = account.getMail();
    String offTel = account.getOffTel();
    String phone = account.getPhone();
    String position = account.getPosition();
    String positionDesc = account.getPositionDesc();
    String remark = account.getRemark();
    String userId = account.getUserId();
    String userName = account.getUserName();

    account.setHomeAddress(homeAddress.trim());
    account.setHomeTel(homeTel.trim());
    account.setId(id.trim());
    account.setMail(mail.trim());
    account.setOffTel(offTel.trim());
    account.setPhone(phone.trim());
    account.setPosition(position.trim());
    account.setPositionDesc(positionDesc.trim());
    account.setRemark(remark.trim());
    account.setUserId(userId.trim());
    account.setUserName(userName.trim());
    account.setType(1);
    account.setPassword(id.trim());
    account.setRoles(transListToString(seledRoles));
    try {
      result = String.valueOf(accountManagerService.createAccount(account));
      orgLevAndIdNames = accountManagerService.getOrgLevAndIdNamesByAccountId(session.getId());
      allowedRoles = accountManagerService.getAllowedRolesByAccountId();
    } catch (Exception ex) {
      log.error(ex.getMessage(), ex);
      result = "-1";
      message = "数据库异常";
      resultForLog = AlarmConstants.RESULT_FAIL;
    }
    operationLogService.createOperationLog("createAccount", account.getId(), resultForLog, message);
    StringBuffer msg = new StringBuffer("创建帐号").append(account.getId());
    switch (Integer.parseInt(result)) {
      case 1:
        msg.append("失败,相同工号的帐号已经存在。");
        isSuccess = false;
        break;
      case -1:
        msg.append("失败,数据库异常!");
        isSuccess = false;
        break;
      default:
        msg.append("成功。");
        isSuccess = true;
        break;
    }
    commonBean = new CommonBean(result, msg.toString());
    if (isSuccess) {
      return SUCCESS;
    } else {
      return ERROR;
    }
  }