Example #1
0
 /**
  * 会员联想
  *
  * @param request
  * @param response
  * @param keyword
  * @return
  * @throws IOException
  */
 @RequestMapping("autoCompleMember")
 public @ResponseBody Map<String, String> autoCompleMember(
     HttpServletRequest request, HttpServletResponse response, String keyword) throws IOException {
   MemberQuery mq = new MemberQuery();
   if (keyword != "" && keyword != null) {
     mq.setMemberName(keyword);
   }
   // mq.setMemberTypeB(0);
   List<MemberEntity> list = memberService.queryMembers(mq);
   List strlist = new ArrayList();
   String sb = "";
   for (MemberEntity memberEntity : list) {
     sb =
         "{\"title\":\""
             + memberEntity.getName()
             + "\",\"result\":\""
             + memberEntity.getMemberNo()
             + "\"}";
     strlist.add(sb);
   }
   String json = "{\"data\":" + strlist.toString() + "}";
   response.setCharacterEncoding("UTF-8");
   PrintWriter out = response.getWriter();
   out.print(json);
   out.flush();
   out.close();
   return null;
 }
Example #2
0
  @RequestMapping("enter")
  @ResponseBody
  public void enter(
      String functionId, String url, HttpSession session, HttpServletRequest request) {
    Date enterTime = (Date) session.getAttribute("enterTime");
    Date nowTime = new Date();
    String currentUrl = (String) session.getAttribute("currentUrl");
    String currentFunction = (String) session.getAttribute("currentFunction");
    String nextUrl = (String) session.getAttribute("nextUrl");
    String nextFunction = (String) session.getAttribute("nextFunction");
    if (currentUrl == null) {
      session.setAttribute("currentUrl", request.getHeader("Referer"));
    }
    session.setAttribute("previousUrl", currentUrl);
    session.setAttribute("currentUrl", nextUrl);
    session.setAttribute("nextUrl", url);

    session.setAttribute("previousFunction", currentFunction);
    session.setAttribute("currentFunction", nextFunction);
    session.setAttribute("nextFunction", functionId);

    MemberEntity principal = (MemberEntity) SecurityUtils.getSubject().getPrincipal();
    if (principal != null) {
      MemberLogEntity log = new MemberLogEntity();
      log.setMemberNo(principal.getMemberNo());
      log.setMemberName(principal.getName());
      log.setNowPage(nextUrl);
      log.setNextpage(url);
      log.setPrePage(currentUrl);

      MemberFunctionEntity function = functionService.getFunction(nextFunction);
      if (function != null) {
        log.setNowName(function.getTitle());
      }

      function = functionService.getFunction(functionId);
      if (function != null) {
        log.setNextName(function.getTitle());
      }

      function = functionService.getFunction(currentFunction);
      if (function != null) {
        log.setPreName(function.getTitle());
      }

      log.setCallTime(enterTime);
      log.setIp(getIpAddr(request));
      if (enterTime != null) {
        long waitTime = (nowTime.getTime() - enterTime.getTime()) / 1000;
        log.setWaitTime(waitTime + "");
      }
      logService.addLog(log);
    }
    session.setAttribute("enterTime", nowTime);
  }
Example #3
0
 @RequestMapping("menuMessageCount")
 public @ResponseBody Map<String, Long> menuMessageCount(HttpSession session) throws WebException {
   Map<String, Long> map = new HashMap<>();
   map.put("isNotLogin", 0l);
   try {
     SupervisorPrincipal login = getLoginInfo(session);
     if (login == null) {
       map.put("isNotLogin", 1l);
       return map;
     }
     MemberEntity member = login.getMember();
     Long transMessageCount =
         CometServiceImpl.getCount(
             MessageChannel.MEMBER_TRANS_MESSAGE_COUNT + member.getMemberNo());
     Long sysMessageCount =
         CometServiceImpl.getCount(
             MessageChannel.MEMBER_SYSTEM_MESSAGE_COUNT + member.getMemberNo());
     Long tenderMessageCount =
         CometServiceImpl.getCount(
             MessageChannel.MEMBER_TENDER_MESSAGE_COUNT + member.getMemberNo());
     if (tenderMessageCount <= 0) {
       String key = MessageChannel.MEMBER_TENDER_MESSAGE_COUNT + login.getMember().getMemberNo();
       List<String> userKeys = CometServiceImpl.get(MessageChannel.MEMBER_READTENDER_MESSAGE_KEYS);
       Long totalCount = CometServiceImpl.getCount(MessageChannel.MEMBER_TENDER_MESSAGE_COUNT);
       if (userKeys != null && userKeys.size() > 0) {
         if (!userKeys.contains(key)) {
           CometServiceImpl.setCount(key, totalCount);
           tenderMessageCount = totalCount;
         }
       } else {
         CometServiceImpl.setCount(key, totalCount);
         tenderMessageCount = totalCount;
       }
     }
     Long contractMessageCount =
         CometServiceImpl.getCount(
             MessageChannel.MEMBER_CONTRACT_MESSAGE_COUNT + member.getMemberNo());
     Long payMessageCount =
         CometServiceImpl.getCount(MessageChannel.MEMBER_PAY_MESSAGE_COUNT + member.getMemberNo());
     map.put("transMessageCount", transMessageCount);
     map.put("sysMessageCount", sysMessageCount);
     map.put("tenderMessageCount", tenderMessageCount);
     map.put("contractMessageCount", contractMessageCount);
     map.put("payMessageCount", payMessageCount);
   } catch (Exception e) {
     SxjLogger.error(e.getMessage(), e, this.getClass());
   }
   return map;
 }
Example #4
0
  @RequestMapping(value = "login", method = RequestMethod.POST)
  public String login(
      String memberName,
      String accountName,
      String password,
      HttpSession session,
      HttpServletRequest request,
      ModelMap map) {
    map.put("accountName", accountName);
    map.put("memberName", memberName);
    SupervisorSiteToken token = null;
    SupervisorPrincipal userBean = null;
    AccountEntity account = null;
    if (StringUtils.isNotEmpty(memberName) && StringUtils.isNotEmpty(accountName)) {
      MemberEntity member = memberService.getMemberByName(memberName);
      if (member == null) {
        map.put("message", "会员不存在");
        return LOGIN;
      }
      if (!member.getName().equals(memberName)) {
        map.put("message", "会员名错误");
        return LOGIN;
      }
      if (MemberCheckStateEnum.UNAUDITED.equals(member.getCheckState())) {
        map.put("message", "会员未审核");
        return LOGIN;
      }
      if (MemberStatesEnum.STOP.equals(member.getState())) {
        map.put("message", "会员已冻结");
        return LOGIN;
      }

      account = accountService.getAccountByName(accountName, member.getMemberNo());
      if (account == null) {
        map.put("amessage", "会员子账户不存在");
        return LOGIN;
      }
      if (AccountStatesEnum.STOP.equals(account.getState())) {
        map.put("amessage", "会员子账户已冻结");
        return LOGIN;
      }

      userBean = new SupervisorPrincipal();
      userBean.setAccount(account);
      userBean.setMember(member);
      token = new SupervisorSiteToken(userBean, password);
    } else if (StringUtils.isNotEmpty(memberName) && StringUtils.isEmpty(accountName)) {
      MemberEntity member = memberService.getMemberByName(memberName);
      if (member == null) {
        map.put("message", "会员不存在");
        return LOGIN;
      }
      if (MemberCheckStateEnum.UNAUDITED.equals(member.getCheckState())) {
        map.put("message", "会员未审核");
        return LOGIN;
      }
      if (MemberStatesEnum.STOP.equals(member.getState())) {
        map.put("message", "会员已冻结");
        return LOGIN;
      }
      userBean = new SupervisorPrincipal();
      userBean.setMember(member);
      token = new SupervisorSiteToken(userBean, password);
    } else {
      map.put("message", "公司名称和密码不能为空");
      // map.put("pmessage", "密码不能为空");
      return LOGIN;
    }
    Subject currentUser = SecurityUtils.getSubject();
    try {
      currentUser.login(token);
      PrincipalCollection principals = currentUser.getPrincipals();
      if (userBean.getAccount() != null) {
        SupervisorShiroRedisCache.addToMap(userBean.getAccount().getId(), principals);
      } else {
        SupervisorShiroRedisCache.addToMap(userBean.getMember().getMemberNo(), principals);
      }
    } catch (AuthenticationException e) {
      SxjLogger.error("登陆失败", e, this.getClass());
      map.put("pmessage", "密码错误");
      return LOGIN;
    }
    if (currentUser.isAuthenticated()) {
      session.setAttribute("userinfo", userBean);
      if (account != null) {
        accountService.edit_Login(account.getId());
      }
      return "redirect:" + getBasePath(request) + "index.htm";
    } else {
      map.put("message", "登陆失败");
      return LOGIN;
    }
  }
Example #5
0
  @RequestMapping("index")
  public String ToIndex(HttpServletRequest request, ModelMap map) {
    HttpSession session = request.getSession(false);
    if (session == null || session.getAttribute("userinfo") == null) {
      return LOGIN;
    } else {
      SupervisorPrincipal info = getLoginInfo(session);
      if (info.getAccount() != null && info.getMember() != null) {
        AccountEntity newAccount = accountService.getAccount(info.getAccount().getId());
        if (newAccount == null) {
          return LOGIN;
        }
        if (newAccount.getState().equals(AccountStatesEnum.STOP)) {
          return LOGIN;
        }
        if (StringUtils.isEmpty(newAccount.getPassword())) {
          return LOGIN;
        }
        if (!newAccount.getPassword().equals(info.getAccount().getPassword())) {
          return LOGIN;
        }
        return "site/member/account-index";
      } else if (info.getAccount() == null && info.getMember() != null) {
        List<AreaEntity> cityList = areaService.getChildrenAreas("32");
        MemberEntity member = memberService.getMember(info.getMember().getId());
        if (member.getAccountNum() == null) {
          member.setAccountNum(0);
        }
        map.put("cityList", cityList);
        map.put("member", member);
        if (info.getMember().getFlag()) {

          Long systemMessageCount =
              CometServiceImpl.getCount(
                  MessageChannel.MEMBER_SYSTEM_MESSAGE_COUNT + member.getMemberNo());
          Long transMessageCount =
              CometServiceImpl.getCount(
                  MessageChannel.MEMBER_TRANS_MESSAGE_COUNT + member.getMemberNo());
          Long tenderMessageCount =
              CometServiceImpl.getCount(
                  MessageChannel.MEMBER_TENDER_MESSAGE_COUNT + member.getMemberNo());
          map.put("systemMessageCount", systemMessageCount);
          map.put("transMessageCount", transMessageCount);
          map.put("tenderMessageCount", tenderMessageCount);

          map.put(
              "channelName_sys", MessageChannel.MEMBER_SYSTEM_MESSAGE_COUNT + member.getMemberNo());
          map.put(
              "channelName_trans",
              MessageChannel.MEMBER_TRANS_MESSAGE_COUNT + member.getMemberNo());
          map.put(
              "channelName_tender",
              MessageChannel.MEMBER_TENDER_MESSAGE_COUNT + member.getMemberNo());
          return "site/member/member-profile";
        } else {
          return "site/member/edit-member";
        }
      } else {
        return LOGIN;
      }
    }
  }