| | |
| | | } |
| | | try { |
| | | // host为主机名,clientid即连接MQTT的客户端ID,一般以唯一标识符表示,MemoryPersistence设置clientid的保存形式,默认为以内存保存 |
| | | // String clientId =config.getClientid()+ Constants.getUUID(); |
| | | String clientId =config.getClientid()+(int)(Math.random()*10000); |
| | | String clientId =config.getClientid() +config.getVersion(); |
| | | client = new org.eclipse.paho.client.mqttv3.MqttClient(config.getHost(), clientId,new MemoryPersistence()); |
| | | // MQTT的连接设置 |
| | | MqttConnectOptions options = new MqttConnectOptions(); |
| | |
| | | } |
| | | try { |
| | | // host为主机名,clientid即连接MQTT的客户端ID,一般以唯一标识符表示,MemoryPersistence设置clientid的保存形式,默认为以内存保存 |
| | | // String clientId =config.getClientid()+ Constants.getUUID(); |
| | | String clientId =config.getClientid()+(int)(Math.random()*10000); |
| | | String clientId =config.getSubclientid() +config.getVersion(); |
| | | subClient = new org.eclipse.paho.client.mqttv3.MqttClient(config.getHost(), clientId,new MemoryPersistence()); |
| | | // MQTT的连接设置 |
| | | MqttConnectOptions options = new MqttConnectOptions(); |
| | |
| | | * 授权密码 |
| | | */ |
| | | private String password; |
| | | /** |
| | | * 客户端版本后缀 |
| | | */ |
| | | private String version; |
| | | |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public MqttLog openLock(Locks locks) { |
| | | String topic = Constants.MqttTopic.pub_openLock.replace("+", locks.getId()); |
| | | String topic = Constants.MqttTopic.pub_openLock.replace("{siteId}", locks.getSiteId()).replace("{lockId}", locks.getCode()); |
| | | int result = mqttToolService.pubMessage("{}",topic); |
| | | MqttLog mqttLog = createPushLog(topic,result,"请求开锁_"+locks.getId()); |
| | | return mqttLog; |
| | |
| | | */ |
| | | @Override |
| | | public MqttLog getLockInfo(Locks locks) { |
| | | String topic = Constants.MqttTopic.pub_getLockInfo.replace("+", locks.getId()); |
| | | String topic = Constants.MqttTopic.pub_getLockInfo.replace("{siteId}", locks.getSiteId()).replace("{lockId}", locks.getCode()); |
| | | int result = mqttToolService.pubMessage("{}",topic); |
| | | MqttLog mqttLog = createPushLog(topic,result,"实时查询锁信息_"+locks.getId()); |
| | | return mqttLog; |
| | |
| | | } |
| | | MqttLog mqttLog = new MqttLog(); |
| | | mqttLog.setMsgId(msgId); |
| | | int msgCount =mqttLogMapper.selectCount(new QueryWrapper<MqttLog>().lambda().eq(MqttLog::getMsgId, msgId)); |
| | | int msgCount =mqttLogMapper.selectCount(new QueryWrapper<MqttLog>().lambda().eq(MqttLog::getMsg, param).eq(MqttLog::getType, Constants.ZERO)); |
| | | if(msgCount>0){ |
| | | log.error("mqtt消息订阅==============已消费数据====="+param); |
| | | return; |
| | |
| | | host: tcp://175.27.187.84:1883 |
| | | username: doumee1 |
| | | password: doumee@168 |
| | | version: 001 |
| | | |
| | | tencent: |
| | | map: |
| | |
| | | host: tcp://175.27.187.84:1883 |
| | | username: doumee1 |
| | | password: doumee@168 |
| | | version: 002 |
| | | |
| | | tencent: |
| | | map: |