update 校验channel是否保存

This commit is contained in:
2023-11-18 08:23:11 +08:00
parent 1ffff5e0c3
commit fce5992a26
4 changed files with 30 additions and 12 deletions

View File

@@ -4,12 +4,11 @@ import com.google.common.primitives.Bytes;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.ykc.PileChannelEntity;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.common.util.YKCUtils;
import com.jsowell.netty.factory.YKCOperateFactory;
import com.jsowell.pile.service.IPileBasicInfoService;
import com.jsowell.pile.service.IPileConnectorInfoService;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -24,15 +23,9 @@ public class HeartbeatRequestHandler extends AbstractHandler {
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.HEART_BEAT_CODE.getBytes());
@Autowired
private RedisCache redisCache;
@Autowired
private IPileBasicInfoService pileBasicInfoService;
@Autowired
private IPileConnectorInfoService pileConnectorInfoService;
@Override
public void afterPropertiesSet() throws Exception {
YKCOperateFactory.register(type, this);
@@ -54,6 +47,9 @@ public class HeartbeatRequestHandler extends AbstractHandler {
// 保存时间
saveLastTime(pileSn);
// 校验channel
PileChannelEntity.checkChannel(pileSn, channel);
// 枪号
startIndex += length;
length = 1;

View File

@@ -196,7 +196,7 @@ public class LoginRequestHandler extends AbstractHandler {
if (pileInfoVO != null) {
flag = Constants.zeroByteArray;
// 登录成功保存桩号和channel的关系
PileChannelEntity.put(pileSn, channel);
PileChannelEntity.checkChannel(pileSn, channel);
// 更改桩和该桩下的枪口状态分别为 在线、空闲 公共方法修改状态
pileBasicInfoService.updateStatus(BytesUtil.bcd2Str(ykcDataProtocol.getFrameType()), pileSn, null, null, null);

View File

@@ -9,6 +9,7 @@ import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.ykc.OrderStatusEnum;
import com.jsowell.common.enums.ykc.PileChannelEntity;
import com.jsowell.common.enums.ykc.StartModeEnum;
import com.jsowell.common.enums.ykc.YKCPileFaultReasonEnum;
import com.jsowell.common.util.BytesUtil;
@@ -108,6 +109,9 @@ public class UploadRealTimeMonitorHandler extends AbstractHandler {
// 保存时间
saveLastTime(pileSn);
// 校验channel
PileChannelEntity.checkChannel(pileSn, channel);
// 枪号
startIndex += length;
length = 1;