/** * 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 = "gettracksbyorderid", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody GetMessagesResponse getTracksByOrderId( @RequestBody IdRequest req, HttpServletResponse response, HttpServletRequest request) { GetMessagesResponse rp = new GetMessagesResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); Cookie.checkAdminUser(strId); if (IdRequest.checkParameters(req) <= 0) { return rp; } try { Order order = orderBo.findById(req.getId()); IdBeforeAfterRequest posReq = new IdBeforeAfterRequest(); posReq.setBefore(order.getCreateTime()); posReq.setAfter( order.getDeliverTime() > 0 ? order.getDeliverTime() : order.getCreateTime() * 2); posReq.setCount(500); List<Object> list = positionRequestBo.getTracks(posReq, order.getTruckUserId()); rp.setList(list); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } catch (Exception e) { e.printStackTrace(); rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); } return rp; }
/** * 根据orderId获得运营商定位 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 = "getsmsposbyorderid", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody PositionResponse getSmsPosByOrderId( @RequestBody IdRequest req, HttpServletResponse response, HttpServletRequest request) { PositionResponse rp = new PositionResponse(); rp.setResult(Cookie.RESPONSE_BAD_REQUEST); String strId = SecurityContextHolder.getContext().getAuthentication().getName(); long userId = Cookie.checkCommonUser( strId, response, request, SecurityContextHolder.getContext().getAuthentication()); try { Order order = orderBo.findById(req.getId()); if (order == null) { return rp; } if (System.currentTimeMillis() > order.getExpireTime()) { rp.setResult(Cookie.RESPONSE_TIMEOUT); return rp; } if (!order.getCargoUserId().equals(userId)) { rp.setResult(Cookie.RESPONSE_PERMISSION_DENIED); return rp; } User user = userBo.findById(order.getTruckUserId()); if (user != null) { Position position = positionBo.createIfNull(order.getTruckUserId()); rp.setCarrier(PositionHelper.CHINA_MOBILE); // rp.setCarrier(PositionHelper.validateMobile(user.getTelephone().toString())); if (position.getPositionTime() < (System.currentTimeMillis() - TimeUtils.ONE_MINUTE * 15)) { PositionInfo info = positionBo.getSmsLocation(1, 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())); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } else { rp.setLat(position.getLat()); rp.setLon(position.getLon()); rp.setPositionTime(System.currentTimeMillis()); rp.setResult(Cookie.RESPONSE_SUCCESS); return rp; } } else { rp.setIsRegister(0); UnregisterUser unregisterUser = unregisterUserBo.findById(order.getTruckUserId()); if (unregisterUser != null) { rp.setCarrier(PositionHelper.CHINA_MOBILE); // // rp.setCarrier(PositionHelper.validateMobile(unregisterUser.getTelephone().toString())); if (unregisterUser.getPositionTime() < (System.currentTimeMillis() - TimeUtils.ONE_MINUTE * 15)) { PositionInfo info = unregisterUserBo.getSmsLocation(unregisterUser, 1, userId); rp.setLat(info.getLat()); rp.setLon(info.getLon()); rp.setSmsLocate(info.getType()); rp.setPositionTime(System.currentTimeMillis()); rp.setSmsLocateReplyNumber( PositionHelper.getLocateReplyNumber(unregisterUser.getTelephone().toString())); 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); } } } } catch (Exception e) { e.printStackTrace(); rp.setResult(Cookie.RESPONSE_SERVER_QUERY_ERROR); } return rp; }