| | |
| | | public ResponseEntity<List<MobilePosition>> positions(@PathVariable String deviceId, |
| | | @RequestParam(required = false) String start, |
| | | @RequestParam(required = false) String end) { |
| | | if (logger.isDebugEnabled()) { |
| | | logger.debug("查询设备" + deviceId + "的历史轨迹"); |
| | | } |
| | | // if (logger.isDebugEnabled()) { |
| | | // logger.debug("查询设备" + deviceId + "的历史轨迹"); |
| | | // } |
| | | |
| | | if (StringUtil.isEmpty(start)) { |
| | | start = null; |
| | |
| | | }) |
| | | @GetMapping("/latest/{deviceId}") |
| | | public ResponseEntity<MobilePosition> latestPosition(@PathVariable String deviceId) { |
| | | if (logger.isDebugEnabled()) { |
| | | logger.debug("查询设备" + deviceId + "的最新位置"); |
| | | } |
| | | // if (logger.isDebugEnabled()) { |
| | | // logger.debug("查询设备" + deviceId + "的最新位置"); |
| | | // } |
| | | MobilePosition result = storager.queryLatestPosition(deviceId); |
| | | return new ResponseEntity<>(result, HttpStatus.OK); |
| | | } |
| | |
| | | String uuid = UUID.randomUUID().toString(); |
| | | String key = DeferredResultHolder.CALLBACK_CMD_MOBILEPOSITION + deviceId; |
| | | cmder.mobilePostitionQuery(device, event -> { |
| | | Response response = event.getResponse(); |
| | | RequestMessage msg = new RequestMessage(); |
| | | msg.setId(uuid); |
| | | msg.setKey(key); |
| | | msg.setData(String.format("获取移动位置信息失败,错误码: %s, %s", response.getStatusCode(), response.getReasonPhrase())); |
| | | msg.setData(String.format("获取移动位置信息失败,错误码: %s, %s", event.statusCode, event.msg)); |
| | | resultHolder.invokeResult(msg); |
| | | }); |
| | | DeferredResult<ResponseEntity<MobilePosition>> result = new DeferredResult<ResponseEntity<MobilePosition>>(5*1000L); |