fix: 业务层跳过 JT808 协议的回复消息生成
All checks were successful
aiot-platform CI/CD / build-and-deploy (push) Successful in 6m50s
All checks were successful
aiot-platform CI/CD / build-and-deploy (push) Successful in 6m50s
This commit is contained in:
@@ -23,6 +23,8 @@ import com.viewshanghai.module.iot.dal.tdengine.IotDeviceMessageMapper;
|
||||
import com.viewshanghai.module.iot.service.device.IotDeviceService;
|
||||
import com.viewshanghai.module.iot.service.device.property.IotDevicePropertyService;
|
||||
import com.viewshanghai.module.iot.service.ota.IotOtaTaskRecordService;
|
||||
import com.viewshanghai.module.iot.service.product.IotProductService;
|
||||
import com.viewshanghai.module.iot.dal.dataobject.product.IotProductDO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.base.Objects;
|
||||
@@ -65,6 +67,9 @@ public class IotDeviceMessageServiceImpl implements IotDeviceMessageService {
|
||||
|
||||
@Resource
|
||||
private IotDeviceMessageProducer deviceMessageProducer;
|
||||
|
||||
@Resource
|
||||
private IotProductService productService;
|
||||
|
||||
@Override
|
||||
public void defineDeviceMessageStable() {
|
||||
@@ -172,11 +177,21 @@ public class IotDeviceMessageServiceImpl implements IotDeviceMessageService {
|
||||
// 条件1:防止对"回复消息"再次回复,避免无限循环
|
||||
// 条件2:某些特定的method不需要回复(如设备状态变更、OTA进度上报)
|
||||
// 条件3(新增):HTTP短连接场景,因为已经在请求中直接响应了,不需要再通过消息总线发送回复
|
||||
// 条件4(新增):JT808 协议由协议处理器自动生成通用应答(0x8001),业务层不需要生成回复消息
|
||||
if (IotDeviceMessageUtils.isReplyMessage(message)
|
||||
|| IotDeviceMessageMethodEnum.isReplyDisabled(message.getMethod())
|
||||
|| StrUtil.isEmpty(message.getServerId())) {
|
||||
return; // serverId 为空,不记录回复消息
|
||||
}
|
||||
|
||||
// 检查设备的编解码类型,如果是 JT808,则跳过回复消息生成
|
||||
// JT808 协议的回复由协议处理器(Jt808ProtocolHandler)自动生成通用应答
|
||||
IotProductDO product = productService.getProductFromCache(device.getProductId());
|
||||
if (product != null && "JT808".equals(product.getCodecType())) {
|
||||
log.debug("[handleUpstreamDeviceMessage][JT808 协议消息,跳过业务层回复消息生成,由协议处理器自动生成通用应答]");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
IotDeviceMessage replyMessage = IotDeviceMessage.replyOf(message.getRequestId(), message.getMethod(), replyData,
|
||||
serviceException != null ? serviceException.getCode() : null,
|
||||
|
||||
Reference in New Issue
Block a user