| | |
| | | return ResponseResult.error("The " + serviceIdentifier + " method does not exist."); |
| | | } |
| | | |
| | | |
| | | Object data = ""; |
| | | // Add parameter validation. |
| | | if (Objects.nonNull(controlMethodEnum.getClazz())) { |
| | | if (Objects.isNull(param)) { |
| | | return ResponseResult.error(CommonErrorEnum.ILLEGAL_ARGUMENT); |
| | | } |
| | | BasicDeviceProperty basicDeviceProperty = mapper.convertValue(param.getAction(), controlMethodEnum.getClazz()); |
| | | BasicDeviceProperty basicDeviceProperty = null; |
| | | if(serviceIdentifier.equals("sdr_workmode_switch")){ |
| | | basicDeviceProperty= mapper.convertValue(param.getLink_workmode(), controlMethodEnum.getClazz()); |
| | | } |
| | | else |
| | | { |
| | | basicDeviceProperty = mapper.convertValue(param.getAction(), controlMethodEnum.getClazz()); |
| | | } |
| | | if (!basicDeviceProperty.valid()) { |
| | | return ResponseResult.error(CommonErrorEnum.ILLEGAL_ARGUMENT); |
| | | } |
| | |
| | | |
| | | boolean isExist = deviceService.checkDeviceOnline(sn); |
| | | if (!isExist) { |
| | | return ResponseResult.error("The dock is offline."); |
| | | return ResponseResult.error(CommonErrorEnum.DEVICE_OFFLINE.getErrorMsg()); |
| | | } |
| | | String topic = TopicConst.THING_MODEL_PRE + TopicConst.PRODUCT + sn + TopicConst.SERVICES_SUF; |
| | | String bid = UUID.randomUUID().toString(); |
| | |
| | | ServiceReply<EventsOutputReceiver> serviceReply = mapper.convertValue( |
| | | serviceReplyOpt, new TypeReference<ServiceReply<EventsOutputReceiver>>() {}); |
| | | if (ResponseResult.CODE_SUCCESS != serviceReply.getResult()) { |
| | | return ResponseResult.error(serviceReply.getResult(), |
| | | Objects.nonNull(serviceReply.getOutput()) ? serviceReply.getOutput().getStatus() : "errorCode: " |
| | | + serviceReply.getResult()); |
| | | String errorMsg = CommonErrorEnum.getMsgByCode(serviceReply.getResult()); |
| | | return ResponseResult.error(serviceReply.getResult(),errorMsg); |
| | | // return ResponseResult.error(serviceReply.getResult(), |
| | | // Objects.nonNull(serviceReply.getOutput()) ? serviceReply.getOutput().getStatus() : "errorCode: " |
| | | // + serviceReply.getResult()); |
| | | } |
| | | if (controlMethodEnum.getProgress()) { |
| | | RedisOpsUtils.setWithExpire(serviceIdentifier + RedisConst.DELIMITER + bid, sn, |
| | | RedisConst.DEVICE_ALIVE_SECOND * RedisConst.DEVICE_ALIVE_SECOND); |
| | | } |
| | | // 执行操作成功后,更新摄像头内外镜头状态 |
| | | if(RemoteControlMethodEnum.COVER_OPEN == controlMethodEnum) { |
| | | // 打开盖子,切换机场舱内摄像头镜头 |
| | | //打开,摄像头为舱内;将摄像头状态存到redis,格式为:CONVERSTATE:设备SN:1(舱外)或0(舱内) |
| | | _deviceService.setRedisCameraPosition(sn,0); |
| | | } |
| | | if(RemoteControlMethodEnum.COVER_CLOSE == controlMethodEnum) { |
| | | // 关闭盖子,切换机场舱外摄像头镜头 |
| | | //关闭,摄像头为舱外;将摄像头状态存到redis,格式为:CONVERSTATE:设备SN:1(舱外)或0(舱内) |
| | | _deviceService.setRedisCameraPosition(sn,1); |
| | | } |
| | | |
| | | return ResponseResult.success(); |
| | | } |
| | | |