#
18516761980
2022-08-02 34a4e9fd5b50ff34c7bc53addd5adf21fb3654b6
src/main/java/com/zy/core/netty/handle/PackageServerHandler.java
@@ -1,7 +1,10 @@
package com.zy.core.netty.handle;
import com.core.common.DateUtils;
import com.zy.asrs.service.impl.MainServiceImpl;
import com.zy.core.netty.AbstractInboundHandler;
import com.zy.core.netty.cache.ChannelCache;
import com.zy.core.netty.constant.Constant;
import com.zy.core.netty.constant.FireDataType;
import com.zy.core.netty.domain.ChPackage;
import com.zy.core.netty.domain.fire.Fire_3030;
@@ -9,6 +12,7 @@
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
@@ -20,6 +24,8 @@
@ChannelHandler.Sharable
public class PackageServerHandler extends AbstractInboundHandler<ChPackage> {
    @Autowired
    private MainServiceImpl mainService;
    @Override
    protected boolean channelRead0(ChannelHandlerContext ctx, ChPackage pac) {
@@ -27,8 +33,13 @@
        switch (dataType) {
            case HEARTBEAT:
                Fire_3030 fire3030 = new Fire_3030().readFromBytes(pac.getBytes());
                String now = "20" + fire3030.getYear() + "-" + fire3030.getMonth() + "-" + fire3030.getDay()
                        + " " + fire3030.getHour() + ":" + fire3030.getMinute() + ":" + fire3030.getSeconds();
                Constant.FIRE_HEARTBEAT.put(fire3030.getNo().toString(), DateUtils.convert(now));
                break;
            case FIRE_ALARM:
                break;
            default:
                break;