| | |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import javax.sip.message.Response; |
| | | |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| | | import com.genersoft.iot.vmp.service.IDeviceService; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | | import com.genersoft.iot.vmp.vmanager.bean.WVPResult; |
| | | import com.github.pagehelper.util.StringUtil; |
| | | |
| | | import io.swagger.annotations.Api; |
| | |
| | | private final static Logger logger = LoggerFactory.getLogger(MobilePositionController.class); |
| | | |
| | | @Autowired |
| | | private IVideoManagerStorager storager; |
| | | private IVideoManagerStorage storager; |
| | | |
| | | @Autowired |
| | | private SIPCommander cmder; |
| | | |
| | | @Autowired |
| | | private DeferredResultHolder resultHolder; |
| | | |
| | | @Autowired |
| | | private IDeviceService deviceService; |
| | | |
| | | /** |
| | | * 查询历史轨迹 |
| | |
| | | @ApiImplicitParam(name = "start", value = "开始时间", required = true, dataTypeClass = String.class), |
| | | @ApiImplicitParam(name = "end", value = "结束时间", required = true, dataTypeClass = String.class), |
| | | }) |
| | | @GetMapping("/history/{deviceId}") |
| | | public ResponseEntity<List<MobilePosition>> positions(@PathVariable String deviceId, |
| | | @RequestParam(required = false) String start, |
| | | @RequestParam(required = false) String end) { |
| | | if (logger.isDebugEnabled()) { |
| | | logger.debug("查询设备" + deviceId + "的历史轨迹"); |
| | | } |
| | | @GetMapping("/history/{deviceId}/{channelId}") |
| | | public ResponseEntity<WVPResult<List<MobilePosition>>> positions(@PathVariable String deviceId, |
| | | @PathVariable String channelId, |
| | | @RequestParam(required = false) String start, |
| | | @RequestParam(required = false) String end) { |
| | | // if (logger.isDebugEnabled()) { |
| | | // logger.debug("查询设备" + deviceId + "的历史轨迹"); |
| | | // } |
| | | |
| | | if (StringUtil.isEmpty(start)) { |
| | | start = null; |
| | |
| | | if (StringUtil.isEmpty(end)) { |
| | | end = null; |
| | | } |
| | | |
| | | List<MobilePosition> result = storager.queryMobilePositions(deviceId, start, end); |
| | | return new ResponseEntity<>(result, HttpStatus.OK); |
| | | WVPResult<List<MobilePosition>> wvpResult = new WVPResult<>(); |
| | | wvpResult.setCode(0); |
| | | List<MobilePosition> result = storager.queryMobilePositions(deviceId, channelId, start, end); |
| | | wvpResult.setData(result); |
| | | return new ResponseEntity<>(wvpResult, HttpStatus.OK); |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | @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); |
| | | } |
| | |
| | | interval = "5"; |
| | | } |
| | | Device device = storager.queryVideoDevice(deviceId); |
| | | |
| | | device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires)); |
| | | device.setMobilePositionSubmissionInterval(Integer.parseInt(interval)); |
| | | storager.updateDevice(device); |
| | | String result = msg; |
| | | if (cmder.mobilePositionSubscribe(device, Integer.parseInt(expires), Integer.parseInt(interval))) { |
| | | if (deviceService.removeMobilePositionSubscribe(device)) { |
| | | result += ",成功"; |
| | | } else { |
| | | result += ",失败"; |