判断mqtt客户端是否在线

This commit is contained in:
2023-07-17 16:27:28 +08:00
parent 153a9ae1a5
commit 3fc99d6d68
6 changed files with 119 additions and 5 deletions

View File

@@ -14,6 +14,7 @@ import com.njcn.access.pojo.dto.ReqAndResDto;
import com.njcn.access.pojo.po.CsGateway;
import com.njcn.access.service.ICsDeviceService;
import com.njcn.access.service.ICsGatewayService;
import com.njcn.access.utils.MqttUtil;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
@@ -23,6 +24,7 @@ import com.njcn.csdevice.pojo.param.CsLedgerParam;
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.po.MqttUser;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.DicDataFeignClient;
@@ -77,6 +79,8 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
private final RedisUtil redisUtil;
private final MqttUtil mqttUtil;
@Override
@Transactional(rollbackFor = {Exception.class})
public void devRegister(String nDid) {
@@ -94,6 +98,12 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
if (!Objects.equals(code, DicDataEnum.CONNECT_DEV.getCode())){
throw new BusinessException(AccessResponseEnum.DEV_IS_NOT_ZL);
}
//3.判断客户端是否在线
//mqttUtil.judgeClientOnline(nDid);
boolean mqttClient = mqttUtil.judgeClientOnline("access-boot123456");
if (!mqttClient){
throw new BusinessException(AccessResponseEnum.MISSING_CLIENT);
}
//3.MQTT询问装置用的模板并判断库中是否存在模板
//存在则建立关系;不存在则告警出来
SysDicTreePO dictData = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevModel()).getData();