| | |
| | | return PRODUCT_KEY; |
| | | } |
| | | |
| | | @Override |
| | | public CommonFrame sendRRPC(String deviceName, IRequestFrame iRequestFrame) { |
| | | InvokeParam param = new InvokeParam(); |
| | | param.setOperate("1001"); |
| | | param.setFrame(iRequestFrame.getEncodeFrame()); |
| | | InvokeThingServiceResponse.Data data = invokeThing(deviceName, param); |
| | | if (data == null) { |
| | | return null; |
| | | } |
| | | String result = data.getResult(); |
| | | result = result.replace("\\", ""); |
| | | Map map = JSON.parseObject(result, Map.class); |
| | | result = (String) map.get("msg"); |
| | | CommonFrame connectFrame = FrameUtils.transformMessageToFrame(result); |
| | | return connectFrame; |
| | | } |
| | | // @Override |
| | | // public CommonFrame sendRRPC(String deviceName, IRequestFrame iRequestFrame) { |
| | | // InvokeParam param = new InvokeParam(); |
| | | // param.setOperate("1001"); |
| | | // param.setFrame(iRequestFrame.getEncodeFrame()); |
| | | // InvokeThingServiceResponse.Data data = invokeThing(deviceName, param); |
| | | // if (data == null) { |
| | | // return null; |
| | | // } |
| | | // String result = data.getResult(); |
| | | // result = result.replace("\\", ""); |
| | | // Map map = JSON.parseObject(result, Map.class); |
| | | // result = (String) map.get("msg"); |
| | | // CommonFrame connectFrame = FrameUtils.transformMessageToFrame(result); |
| | | // return connectFrame; |
| | | // } |
| | | // |
| | | // @Override |
| | | // public <T extends BaseResponseInnerFrame<T>> WrapResponseCommonFrame<T> sendRRPC(String deviceName, IRequestFrame iRequestFrame, Class<T> clz) { |
| | | // CommonFrame commonFrame = sendRRPC(deviceName, iRequestFrame); |
| | | // if (commonFrame == null) { |
| | | // throw new BusinessException("rrpc请求失败"); |
| | | // } |
| | | // WrapResponseCommonFrame<T> responseCommonFrame = new WrapResponseCommonFrame<>(); |
| | | // BeanUtils.copyProperties(commonFrame, responseCommonFrame); |
| | | // try { |
| | | // responseCommonFrame.setResponseInnerFrame(clz.newInstance().transformFrame(responseCommonFrame.getPayload())); |
| | | // } catch (InstantiationException | IllegalAccessException e) { |
| | | // throw new BusinessException(String.format("找不到%s的构造函数", clz.getName())); |
| | | // } |
| | | // return responseCommonFrame; |
| | | // } |
| | | |
| | | @Override |
| | | public <T extends BaseResponseInnerFrame<T>> WrapResponseCommonFrame<T> sendRRPC(String deviceName, IRequestFrame iRequestFrame, Class<T> clz) { |
| | | CommonFrame commonFrame = sendRRPC(deviceName, iRequestFrame); |
| | | if (commonFrame == null) { |
| | | throw new BusinessException("rrpc请求失败"); |
| | | } |
| | | WrapResponseCommonFrame<T> responseCommonFrame = new WrapResponseCommonFrame<>(); |
| | | BeanUtils.copyProperties(commonFrame, responseCommonFrame); |
| | | try { |
| | | responseCommonFrame.setResponseInnerFrame(clz.newInstance().transformFrame(responseCommonFrame.getPayload())); |
| | | } catch (InstantiationException | IllegalAccessException e) { |
| | | throw new BusinessException(String.format("找不到%s的构造函数", clz.getName())); |
| | | } |
| | | return responseCommonFrame; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String s = "FEA581000BFE010003FFFF004597147735AB2D28"; |
| | | System.out.println(FrameUtils.decodeReportMessage(s)); |
| | | } |
| | | |
| | | private static class SingletonClassInstance { |
| | | private static final MainBoardInvokeSyncService INSTANCE = new MainBoardInvokeSyncService(); |
| | | } |
| | | |
| | | private MainBoardInvokeSyncService() { |
| | | protected MainBoardInvokeSyncService() { |
| | | } |
| | | |
| | | public static MainBoardInvokeSyncService getInstance() { |