|  |  |  | 
|---|
|  |  |  | 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.gb28181.utils.XmlUtil; | 
|---|
|  |  |  | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.http.HttpStatus; | 
|---|
|  |  |  | import org.springframework.http.ResponseEntity; | 
|---|
|  |  |  | import org.springframework.util.StringUtils; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | import org.springframework.web.context.request.async.DeferredResult; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | cmder.recordCmd(device, channelId, recordCmdStr, event -> { | 
|---|
|  |  |  | Response response = event.getResponse(); | 
|---|
|  |  |  | RequestMessage msg = new RequestMessage(); | 
|---|
|  |  |  | msg.setId(DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (XmlUtil.isEmpty(channelId) ? deviceId : channelId)); | 
|---|
|  |  |  | msg.setId(DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (StringUtils.isEmpty(channelId) ? deviceId : channelId)); | 
|---|
|  |  |  | msg.setData(String.format("开始/停止录像操作失败,错误码: %s, %s", response.getStatusCode(), response.getReasonPhrase())); | 
|---|
|  |  |  | resultHolder.invokeResult(msg); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | 
|---|
|  |  |  | logger.warn(String.format("开始/停止录像操作超时, 设备未返回应答指令")); | 
|---|
|  |  |  | // 释放rtpserver | 
|---|
|  |  |  | RequestMessage msg = new RequestMessage(); | 
|---|
|  |  |  | msg.setId(DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (XmlUtil.isEmpty(channelId) ? deviceId : channelId)); | 
|---|
|  |  |  | msg.setId(DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (StringUtils.isEmpty(channelId) ? deviceId : channelId)); | 
|---|
|  |  |  | msg.setData("Timeout. Device did not response to this command."); | 
|---|
|  |  |  | resultHolder.invokeResult(msg); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | resultHolder.put(DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (XmlUtil.isEmpty(channelId) ? deviceId : channelId), result); | 
|---|
|  |  |  | resultHolder.put(DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (StringUtils.isEmpty(channelId) ? deviceId : channelId), result); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * @param   deviceId 设备ID | 
|---|
|  |  |  | * @param   guardCmdStr SetGuard:布防,ResetGuard:撤防 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @ApiOperation("录像控制命令") | 
|---|
|  |  |  | @ApiOperation("布防/撤防命令") | 
|---|
|  |  |  | @ApiImplicitParams({ | 
|---|
|  |  |  | @ApiImplicitParam(name = "deviceId", value = "设备ID", required = true, dataTypeClass = String.class), | 
|---|
|  |  |  | @ApiImplicitParam(name = "guardCmdStr", value ="命令, 可选值:SetGuard(布防),ResetGuard(撤防)", required = true, | 
|---|
|  |  |  | 
|---|
|  |  |  | cmder.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, event -> { | 
|---|
|  |  |  | Response response = event.getResponse(); | 
|---|
|  |  |  | RequestMessage msg = new RequestMessage(); | 
|---|
|  |  |  | msg.setId(DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (XmlUtil.isEmpty(channelId) ? deviceId : channelId)); | 
|---|
|  |  |  | msg.setId(DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (StringUtils.isEmpty(channelId) ? deviceId : channelId)); | 
|---|
|  |  |  | msg.setData(String.format("看守位控制操作失败,错误码: %s, %s", response.getStatusCode(), response.getReasonPhrase())); | 
|---|
|  |  |  | resultHolder.invokeResult(msg); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | 
|---|
|  |  |  | logger.warn(String.format("看守位控制操作超时, 设备未返回应答指令")); | 
|---|
|  |  |  | // 释放rtpserver | 
|---|
|  |  |  | RequestMessage msg = new RequestMessage(); | 
|---|
|  |  |  | msg.setId(DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (XmlUtil.isEmpty(channelId) ? deviceId : channelId)); | 
|---|
|  |  |  | msg.setId(DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (StringUtils.isEmpty(channelId) ? deviceId : channelId)); | 
|---|
|  |  |  | JSONObject json = new JSONObject(); | 
|---|
|  |  |  | json.put("DeviceID", deviceId); | 
|---|
|  |  |  | json.put("Status", "Timeout"); | 
|---|
|  |  |  | 
|---|
|  |  |  | msg.setData(json); //("看守位控制操作超时, 设备未返回应答指令"); | 
|---|
|  |  |  | resultHolder.invokeResult(msg); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | resultHolder.put(DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (XmlUtil.isEmpty(channelId) ? deviceId : channelId), result); | 
|---|
|  |  |  | resultHolder.put(DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (StringUtils.isEmpty(channelId) ? deviceId : channelId), result); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|