update 电单车协议

This commit is contained in:
Guoqs
2024-08-28 15:21:49 +08:00
parent 16572c6bdf
commit 4e69180aa8
12 changed files with 98 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
package com.jsowell.pile.service.impl;
import com.jsowell.common.enums.ykc.PileChannelEntity;
import com.jsowell.pile.domain.ebike.AbsEBikeMessage;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* 电单车发送指令service
*/
@Slf4j
@Service
public class EBikeSendCommandService {
/**
* 公共方法发送指令
* @param pileSn 装编号
* @param msg 消息
* @param timeout 超时时间
* @param unit 时间单位
*/
private void sendCommand(String pileSn, Class<? extends AbsEBikeMessage> msg, long timeout, TimeUnit unit) {
// 通过桩编号获取channel
ChannelHandlerContext ctx = PileChannelEntity.getChannelByPileSn(pileSn);
if (Objects.isNull(ctx)) {
log.error("push命令[{}]失败, 桩号:{}无法获取到长连接, 请检查充电桩连接状态!", "value", pileSn);
throw new NullPointerException("channel");
}
}
}