| | |
| | | import com.aliyuncs.exceptions.ClientException; |
| | | import com.aliyuncs.iot.model.v20180120.*; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.ximon.admin.localMQTT.util.MqttClientUtil; |
| | | import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.BaseResponseInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | |
| | | import java.util.Base64; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | @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, false); |
| | | if (data == null) { |
| | | return null; |
| | | } |
| | | String result = data.getResult(); |
| | | result = result.replace("\\", ""); |
| | | Map map = JSON.parseObject(result, Map.class); |
| | | result = (String) map.get("msg"); |
| | | // InvokeParam param = new InvokeParam(); |
| | | // param.setOperate("1001"); |
| | | // param.setFrame(iRequestFrame.getEncodeFrame()); |
| | | // InvokeThingServiceResponse.Data data = invokeThing(deviceName, param, false); |
| | | // if (data == null) { |
| | | // return null; |
| | | // } |
| | | // String result = data.getResult(); |
| | | // result = result.replace("\\", ""); |
| | | // Map map = JSON.parseObject(result, Map.class); |
| | | // result = (String) map.get("msg"); |
| | | String frame = FrameUtils.transformMessageToFrame(iRequestFrame.getEncodeFrame()).toString(); |
| | | String result = MqttClientUtil.sendMqttMsg(deviceName,frame); |
| | | return FrameUtils.transformMessageToFrame(result); |
| | | } |
| | | |
| | | @Override |
| | | public CommonFrame sendRRPC(String deviceName, IRequestFrame iRequestFrame, boolean resendFlag) { |
| | | InvokeParam param = new InvokeParam(); |
| | | param.setOperate("1001"); |
| | | param.setFrame(iRequestFrame.getEncodeFrame()); |
| | | InvokeThingServiceResponse.Data data = invokeThing(deviceName, param, true); |
| | | if (data == null) { |
| | | return null; |
| | | } |
| | | String result = data.getResult(); |
| | | result = result.replace("\\", ""); |
| | | Map map = JSON.parseObject(result, Map.class); |
| | | result = (String) map.get("msg"); |
| | | // InvokeParam param = new InvokeParam(); |
| | | // param.setOperate("1001"); |
| | | // param.setFrame(iRequestFrame.getEncodeFrame()); |
| | | // InvokeThingServiceResponse.Data data = invokeThing(deviceName, param, true); |
| | | // if (data == null) { |
| | | // return null; |
| | | // } |
| | | // String result = data.getResult(); |
| | | // result = result.replace("\\", ""); |
| | | // Map map = JSON.parseObject(result, Map.class); |
| | | // result = (String) map.get("msg"); |
| | | String frame = FrameUtils.transformMessageToFrame(iRequestFrame.getEncodeFrame()).toString(); |
| | | String result = MqttClientUtil.sendMqttMsg(deviceName,frame); |
| | | return FrameUtils.transformMessageToFrame(result); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 基础通信同步调用 |
| | | * |