Ejemplo n.º 1
0
 /**
  * 退出登录
  *
  * @return
  */
 public String logout() {
   UserInfo user = getOnlineUser();
   if (user != null) {
     OperationLog ol = new OperationLog();
     ol.setUserId(user.getEntityId());
     ol.setUserName(user.getName());
     ol.setDetail("login.action");
     ol.setUrl("logout.action");
     ol.setIp(getRequest().getRemoteAddr());
     try {
       this.getBaseService().save(ol);
     } catch (Exception ex) {
       log.error(ex.getMessage(), ex);
     }
   }
   try {
     this.setOnlineUser(null);
     this.getSession().clear();
     HttpSession session = getRequest().getSession();
     session.invalidate(); // 移出所有
   } catch (Exception e) {
     log.error(e.getMessage(), e);
   }
   return "success";
 }
Ejemplo n.º 2
0
 protected void SendCommand(TerminalCommand tc) {
   VehicleData vd = vehicleService.getVehicleData(getVehicleId());
   tc.setPlateNo(vd.getPlateNo());
   tc.setSimNo(vd.getSimNo());
   tc.setVehicleId(vd.getEntityId());
   UserInfo onlineUser = getOnlineUser();
   if (onlineUser != null) {
     tc.setUserId(onlineUser.getEntityId());
     tc.setOwner(onlineUser.getName());
   }
   getTerminalService().SendCommand(tc);
 }
Ejemplo n.º 3
0
  public String login() {

    if (StringUtil.isEmpty(this.username)) {
      setMessage("用户名不能为空");
      return json(false, super.getMessage());
    }
    if (this.password == null) {
      setMessage("密码不能为空");
      return json(false, super.getMessage());
    }

    try {
      String hsql = "from UserInfo where loginName = ? and userState <> ? and deleted = ?";

      UserInfo user =
          (UserInfo)
              this.getBaseService()
                  .find(hsql, new Object[] {username, UserInfo.STATE_SUSPEND, false});

      if (user == null) {
        setMessage("用户名或密码错误");
        return json(false, super.getMessage());
      }
      String userpassword = null;

      userpassword = user.getPassword();

      String pwd = StringUtil.encodePassword(userpassword, "md5");

      if (!userpassword.equalsIgnoreCase(this.password)) {
        setMessage("用户名或密码不正确");
        return json(false, super.getMessage());
      }

      // user.setUserType(this.userType);
      String hostName = getRequest().getRemoteHost();
      user.setIp(hostName);
      if (user.getRoles().size() < 1) {
        Role role = new Role();
        role.setName("ROLE_ADMIN");
        user.getRoles().add(role);
      }
      user.setLoginTime(new Date());
      MobileOnlineUser.onlineUserMap.put(user.getEntityId(), user);
      authorizedFuncs = new ArrayList();
      if (user.getUserFlag() == UserInfo.USER_FLAG_SUPER_ADMIN) {
        // 如果是超级用户,将加所有权限,可以分配所有管理部门
        authorizedFuncs = this.getBaseService().loadAll(FuncModel.class);
      } else {
        Role r = user.getRole();
        if (r != null) {
          authorizedFuncs.addAll(r.getFuncs());
        }
      }
      // 移动端的权限
      List funcResult = new ArrayList();
      Map userInfoMap = new HashMap();
      // Map funcMap = new HashMap();
      for (FuncModel f : authorizedFuncs) {
        if (f.getFuncType() == FuncModel.FUNC_TYPE_MOBILE) {
          funcResult.add(f.getFuncName());
          // funcMap.put(f.getFuncName(), f.getFuncName());
        }
      }

      userInfoMap.put("funcs", funcResult);
      SystemConfig sc = (SystemConfig) this.getBaseService().load(SystemConfig.class, 1);

      userInfoMap.put("id", user.getEntityId());
      userInfoMap.put("name", user.getName());
      userInfoMap.put("loginName", user.getLoginName());

      userInfoMap.put("mapCenterLat", user.getMapCenterLat());
      if (user.getMapCenterLat() > 0) {
        sc.setInitLat(user.getMapCenterLat());
      }
      if (user.getMapCenterLng() > 0) {
        sc.setInitLng(user.getMapCenterLng());
      }

      userInfoMap.put("mapCenterLng", user.getMapCenterLng());

      if (user.getMapLevel() > 0) {
        userInfoMap.put("mapZoom", user.getMapLevel());

        sc.setInitZoomLevel(user.getMapLevel());
      } else {
        userInfoMap.put("mapZoom", 15);
      }

      if (user.getRoles().size() < 1) {
        // if (user.getUserType() == 0) {
        Role role = new Role();
        // role.setDescription(getText("administrator"));
        role.setName("ROLE_ADMIN");
        user.getRoles().add(role);
        // }
      }
      Role r = user.getRole();
      userInfoMap.put("roleName", r.getName());

      // JSONArray roleArray = JSONArray.fromObject(user.getRoles(),
      // this.jsonConfig);

      getSession().put(SESSION_KEY_SYSTEM_CONFIG, sc);

      super.setOnlineUser(user);
      super.setAuthorizedDep(user);

      this.LogOperation("移动端登录");

      return json(true, userInfoMap);
    } catch (Exception e) {
      this.log.error(e.getMessage(), e);
      return json(false, e.getMessage());
    }
  }