/** * Accepts a POST request with an XML message parameter * * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping( value = "gettracks", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetTrackResponse getTracks( @RequestBody IdBeforeAfterRequest req, HttpServletResponse response, HttpServletRequest request) { GetTrackResponse rp = new GetTrackResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long userId = Cookie.checkCommonUser( strId, response, request, SecurityContextHolder.getContext().getAuthentication()); if (BeforeAfterRequest.checkParameters(req) <= 0) { return rp; } try { User user = userBo.findById(req.getId()); Profile profile = profileBo.findById(req.getId()); if (user == null || profile == null) { rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } DriverInfo info = new DriverInfo(profile, user); rp.setInfo(info); int count = req.getCount(); req.setCount(count + 1); List<Object> list = positionRequestBo.getTracks(req, userId); rp.setAll(Cookie.calcIsAll(list, count)); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } catch (Exception e) { e.printStackTrace(); rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); } return rp; }
/** * 根据用户id获得运营商定位 Accepts a POST request with an XML message parameter * * @param message serialized Message object * @return a string with the result of the POST */ @RequestMapping( value = "getsmspos", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetSmsLocateResponse getSmsPos( @RequestBody IdTypeRequest req, HttpServletResponse response, HttpServletRequest request) { GetSmsLocateResponse rp = new GetSmsLocateResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long userId = Cookie.checkCommonUser( strId, response, request, SecurityContextHolder.getContext().getAuthentication()); try { Profile profile = profileBo.findById(userId); if (profile.getMemberLocateCount() <= 0) { rp.setResult(Cookie.RESPONSE_NOT_ENOUGH); return rp; } rp.setCount(profile.getMemberLocateCount()); User user = userBo.findById(req.getId()); if (user != null) { // int carrier = PositionHelper.validateMobile(user.getTelephone().toString()); Position pos = positionBo.createIfNull(req.getId()); rp.setCarrier(PositionHelper.CHINA_MOBILE); if (pos.getPositionTime() < (System.currentTimeMillis() - TimeUtils.ONE_MINUTE * 5)) { PositionInfo info = positionBo.getSmsLocation(req.getType(), userId, user.getTelephone(), user); rp.setLat(info.getLat()); rp.setLon(info.getLon()); rp.setSmsLocate(info.getType()); rp.setPositionTime(System.currentTimeMillis()); rp.setSmsLocateReplyNumber( PositionHelper.getLocateReplyNumber(user.getTelephone().toString())); if (info.getType() == Constant.SMS_LOCATE_SUCCESS) { profileBo.detractMemberLocateCount(userId); rp.setCount(profile.getMemberLocateCount() - 1); } rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } else { rp.setLat(pos.getLat()); rp.setLon(pos.getLon()); rp.setPositionTime(System.currentTimeMillis()); rp.setResult(Cookie.RESPONSE_SUCCESS); profileBo.detractMemberLocateCount(userId); rp.setCount(profile.getMemberLocateCount() - 1); return rp; } } else { UnregisterUser unregisterUser = unregisterUserBo.findById(req.getId()); // int carrier = PositionHelper.validateMobile(unregisterUser.getTelephone().toString()); rp.setCarrier(PositionHelper.CHINA_MOBILE); if (unregisterUser != null) { rp.setCount(profile.getMemberLocateCount()); if (unregisterUser.getPositionTime() < (System.currentTimeMillis() - TimeUtils.ONE_MINUTE * 5)) { PositionInfo info = unregisterUserBo.getSmsLocation(unregisterUser, req.getType(), userId); rp.setLat(info.getLat()); rp.setLon(info.getLon()); rp.setSmsLocate(info.getType()); rp.setPositionTime(System.currentTimeMillis()); rp.setSmsLocateReplyNumber( PositionHelper.getLocateReplyNumber(unregisterUser.getTelephone().toString())); if (info.getType() == Constant.SMS_LOCATE_SUCCESS) { profileBo.detractMemberLocateCount(userId); rp.setCount(profile.getMemberLocateCount() - 1); } rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } else { rp.setLat(unregisterUser.getLat()); rp.setLon(unregisterUser.getLon()); rp.setPositionTime(System.currentTimeMillis()); rp.setResult(Cookie.RESPONSE_SUCCESS); profileBo.detractMemberLocateCount(userId); rp.setCount(profile.getMemberLocateCount() - 1); } } } } catch (Exception e) { e.printStackTrace(); rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); } return rp; }