|
|
@@ -1,46 +0,0 @@
|
|
|
-package com.inspur.netty.handler;
|
|
|
-
|
|
|
-import com.inspur.device.domain.SmsbOtaRecord;
|
|
|
-import com.inspur.device.mapper.SmsbOtaRecordMapper;
|
|
|
-import com.inspur.netty.message.receive.ReceiveMessageType;
|
|
|
-import io.netty.channel.ChannelHandlerContext;
|
|
|
-import io.netty.channel.ChannelInboundHandlerAdapter;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.dromara.common.core.utils.SpringUtils;
|
|
|
-
|
|
|
-/**
|
|
|
- * 设备OTA check replay handler
|
|
|
- *
|
|
|
- * @author lihao16
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-public class OTACheckReplayHandler extends ChannelInboundHandlerAdapter {
|
|
|
-
|
|
|
- private static final SmsbOtaRecordMapper smsbOtaRecordMapper = SpringUtils.getBean(SmsbOtaRecordMapper.class);
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
|
|
- String message = (String) msg;
|
|
|
- // 处理/ota/check/replay消息
|
|
|
- if (message.contains(ReceiveMessageType.DEVICE_CHECK_OTA_REPLAY.getValue())) {
|
|
|
- log.info("OTACheckReplayHandler : receive OTA check replay message :{}", message);
|
|
|
- Long recordId = Long.valueOf(message.split("/")[4]);
|
|
|
- Integer status = Integer.parseInt(message.split("/")[5]);
|
|
|
- updateOTARecordStatus(recordId, status);
|
|
|
- /*String heartbeatReplay = identifier + PushMessageType.CONTENT_DOWNLOAD_STATUS_REPLAY.getValue();
|
|
|
- ByteBuf byteBuf = Unpooled.copiedBuffer(heartbeatReplay + NettyConstants.DATA_PACK_SEPARATOR, Charset.forName("utf-8"));
|
|
|
- ctx.channel().writeAndFlush(byteBuf);*/
|
|
|
-
|
|
|
- } else {
|
|
|
- ctx.fireChannelRead(message);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void updateOTARecordStatus(Long recordId, Integer status) {
|
|
|
- SmsbOtaRecord smsbOtaRecord = new SmsbOtaRecord();
|
|
|
- smsbOtaRecord.setId(recordId);
|
|
|
- smsbOtaRecord.setOtaStatus(status);
|
|
|
- smsbOtaRecordMapper.updateById(smsbOtaRecord);
|
|
|
- }
|
|
|
-}
|