feat:【IoT 物联网】新增设备信息查询功能,优化 MQTT 消息处理逻辑

This commit is contained in:
haohao
2025-06-10 10:21:24 +08:00
parent 800a85f7bc
commit 4ea6e08f99
16 changed files with 759 additions and 182 deletions

View File

@@ -4,6 +4,9 @@ import cn.iocoder.yudao.framework.common.enums.RpcConstants;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.iot.core.biz.IotDeviceCommonApi;
import cn.iocoder.yudao.module.iot.core.biz.dto.IotDeviceAuthReqDTO;
import cn.iocoder.yudao.module.iot.core.biz.dto.IotDeviceInfoReqDTO;
import cn.iocoder.yudao.module.iot.core.biz.dto.IotDeviceInfoRespDTO;
import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
@@ -35,4 +38,25 @@ public class IoTDeviceApiImpl implements IotDeviceCommonApi {
return success(deviceService.authDevice(authReqDTO));
}
@Override
@PostMapping(RpcConstants.RPC_API_PREFIX + "/iot/device/info")
@PermitAll
public CommonResult<IotDeviceInfoRespDTO> getDeviceInfo(@RequestBody IotDeviceInfoReqDTO infoReqDTO) {
IotDeviceDO device = deviceService.getDeviceByProductKeyAndDeviceNameFromCache(
infoReqDTO.getProductKey(), infoReqDTO.getDeviceName());
if (device == null) {
return success(null);
}
IotDeviceInfoRespDTO respDTO = new IotDeviceInfoRespDTO();
respDTO.setDeviceId(device.getId());
respDTO.setProductKey(device.getProductKey());
respDTO.setDeviceName(device.getDeviceName());
respDTO.setDeviceKey(device.getDeviceKey());
respDTO.setTenantId(device.getTenantId());
return success(respDTO);
}
}