| | |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.github.pagehelper.util.StringUtil; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.context.request.async.DeferredResult; |
| | | |
| | | /** |
| | | * 位置信息管理 |
| | | */ |
| | | @Api(tags = "位置信息管理") |
| | | @CrossOrigin |
| | | @RestController |
| | | @RequestMapping("/api") |
| | | @RequestMapping("/api/position") |
| | | public class MobilePositionController { |
| | | |
| | | private final static Logger logger = LoggerFactory.getLogger(MobilePositionController.class); |
| | |
| | | |
| | | @Autowired |
| | | private DeferredResultHolder resultHolder; |
| | | |
| | | @GetMapping("/positions/{deviceId}/history") |
| | | |
| | | /** |
| | | * 查询历史轨迹 |
| | | * @param deviceId 设备ID |
| | | * @param start 开始时间 |
| | | * @param end 结束时间 |
| | | * @return |
| | | */ |
| | | @ApiOperation("查询历史轨迹") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "deviceId", value = "设备ID", required = true), |
| | | @ApiImplicitParam(name = "start", value = "开始时间", required = true), |
| | | @ApiImplicitParam(name = "end", value = "结束时间", required = true), |
| | | }) |
| | | @GetMapping("/history/{deviceId}") |
| | | public ResponseEntity<List<MobilePosition>> positions(@PathVariable String deviceId, |
| | | @RequestParam(required = false) String start, |
| | | @RequestParam(required = false) String end) { |
| | |
| | | return new ResponseEntity<>(result, HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping("/positions/{deviceId}/latest") |
| | | /** |
| | | * 查询设备最新位置 |
| | | * @param deviceId 设备ID |
| | | * @return |
| | | */ |
| | | @ApiOperation("查询设备最新位置") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "deviceId", value = "设备ID", required = true), |
| | | }) |
| | | @GetMapping("/latest/{deviceId}") |
| | | public ResponseEntity<MobilePosition> latestPosition(@PathVariable String deviceId) { |
| | | if (logger.isDebugEnabled()) { |
| | | logger.debug("查询设备" + deviceId + "的最新位置"); |
| | |
| | | return new ResponseEntity<>(result, HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping("/positions/{deviceId}/realtime") |
| | | /** |
| | | * 获取移动位置信息 |
| | | * @param deviceId 设备ID |
| | | * @return |
| | | */ |
| | | @ApiOperation("获取移动位置信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "deviceId", value = "设备ID", required = true), |
| | | }) |
| | | @GetMapping("/realtime/{deviceId}") |
| | | public DeferredResult<ResponseEntity<MobilePosition>> realTimePosition(@PathVariable String deviceId) { |
| | | Device device = storager.queryVideoDevice(deviceId); |
| | | cmder.mobilePostitionQuery(device, event -> { |
| | |
| | | return result; |
| | | } |
| | | |
| | | @GetMapping("/positions/{deviceId}/subscribe") |
| | | /** |
| | | * 订阅位置信息 |
| | | * @param deviceId 设备ID |
| | | * @param expires 订阅超时时间 |
| | | * @param interval 上报时间间隔 |
| | | * @return true = 命令发送成功 |
| | | */ |
| | | @ApiOperation("订阅位置信息") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "deviceId", value = "设备ID", required = true), |
| | | @ApiImplicitParam(name = "expires", value = "订阅超时时间"), |
| | | @ApiImplicitParam(name = "interval", value = "上报时间间隔"), |
| | | }) |
| | | @GetMapping("/subscribe/{deviceId}") |
| | | public ResponseEntity<String> positionSubscribe(@PathVariable String deviceId, |
| | | @RequestParam String expires, |
| | | @RequestParam String interval) { |