Pu Zhibing
2025-04-27 2e1766b31e889d9ee54d433476d031220dfda294
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.ruoyi.dataInterchange.server;
 
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.dataInterchange.dao.UPAuthorizeMsgStartupDao;
import com.ruoyi.dataInterchange.model.UPAuthorizeMsgStartup;
import com.ruoyi.dataInterchange.util.jtt809.packet.common.OuterPacket;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
 
/**
 * 主链路视频时效口令交互
 *
 * @author zhibing.pu
 * @Date 2025/3/21 10:45
 */
@Slf4j
@Service
public class AuthorizeMsgService {
    
    @Resource
    private RedisTemplate redisTemplate;
    
    @Resource
    private UPAuthorizeMsgStartupDao upAuthorizeMsgStartupDao;
    
    public void up_authorize_msg(ChannelHandlerContext ctx, OuterPacket out) {
        if (!redisTemplate.hasKey("login:" + out.getGnsscenterId())) {
            log.error("链路还未登录校验,拒绝连接");
            ctx.close();
            return;
        }
        byte[] body = out.getBody();
        ByteBuf byteBuf = Unpooled.wrappedBuffer(body);
        UPAuthorizeMsgStartup startup = new UPAuthorizeMsgStartup().decode(byteBuf);
        log.info("视频时效口令上报:" + JSON.toJSONString(startup));
        startup.setInferiorPlatformId(out.getGnsscenterId());
        startup.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)));
        if(StringUtils.isNotEmpty(startup.getAuthorizeCode1())){
            upAuthorizeMsgStartupDao.save(startup);
        }
    }
}